### 5.1.89 memory

`Syntax:`
  `memory (` int_expression `)`
`Type:`
  bigint
`Purpose:`
  returns statistics concerning the memory management:
  - `memory(0)` is the number of active (used) bytes,
  - `memory(1)` is the number of bytes allocated from the operating system,
  - `memory(2)` is the maximal number of bytes ever allocated from the operating system during the current SINGULAR session.
`Note:`
  To monitor the memory usage during ongoing computations the option `mem` should be set (using the command `option(mem);`, see also option).
`Example:`

        ring r=0,(x(1..500)),dp;
        poly p=(x(1)+x(500))^50;
        proc ReportMemoryUsage()
        {  "Memory currently used by SINGULAR     :",memory(0),"Byte (",
           int(memory(0) div 1024), "KByte)" +newline+
           "Memory currently allocated from system:",memory(1), "Byte (",
           int(memory(1) div 1024), "KByte)";
           "Maximal memory allocated from system  :",memory(2), "Byte (",
           int(memory(2) div 1024), "KByte)";
        }
        ReportMemoryUsage();
      ==> Memory currently used by SINGULAR     : 153568 Byte ( 150 KByte)
      ==> Memory currently allocated from system: 2157280 Byte ( 2106 KByte)
      ==> Maximal memory allocated from system  : 2213312 Byte ( 2161 KByte)
        kill p;
        ReportMemoryUsage(); // less memory used: p killed
      ==> Memory currently used by SINGULAR     : 83000 Byte ( 77 KByte)
      ==> Memory currently allocated from system: 2157280 Byte ( 2106 KByte)
      ==> Maximal memory allocated from system  : 2213312 Byte ( 2161 KByte)
        kill r;
        ReportMemoryUsage(); // even less memory: r killed
      ==> Memory currently used by SINGULAR     : 70760 Byte ( 69 KByte)
      ==> Memory currently allocated from system: 2150248 Byte ( 2099 KByte)
      ==> Maximal memory allocated from system  : 2213312 Byte ( 2161 KByte)

See option; system.

User manual for Singular version 4.4.1, 2025, generated by texi2html.