The c-tree Server for Windows has an option that causes c-tree's memory suballocator to collect call stacks for each allocation call made through ctgetmem(). Each memory allocation is assigned a sequence number. The ctMEMSTAT() API function can be used to read the current allocation sequence number and the current number of allocations and to log the call stacks for the allocations to the specified file.
For Windows and Linux systems, this option is ON by default in V10.4 and later.
The ctstat utility supports the following new memory tracking options:
C:\>ctstat -ms -h 10 -s FAIRCOMS
C:\>ctstat -mf memfull.log -i 1 1 -s FAIRCOMS
A log of all memory allocations (with each allocation listed separately) is written to the file memfull.log in the c-tree Server's working directory.
C:\>ctstat -ma memaggr.log -i 1 1 -s FAIRCOMS
A log of all memory allocations (with allocations having the same call stack listed only once each) is written to the file memaggr.log in the c-tree Server's working directory.
C:\>ctstat -ma memaggr.log -mr 1900,2000 -i 1 1 -s FAIRCOMS
A log of all memory allocations that have sequence numbers between 1900 and 2000 is written to the file memaggr.log in the c-tree Server's working directory.
For windows, -ma or -mf require debug symbols files (ctreedbs.pdb) for callstacks to be generated. These can be provided by faircom support if excessive memory usage is being investigated. ctstat -mu will attempt to reload this symbol file.
Note: These options will fail with error 170 if used with a c-tree Server that was built prior to our introduction of this feature and will fail with error 454 if used with a c-tree Server that was built after the introduction of this feature but that was not compiled with #define ctFeatMEMTRACK.