4.10.1.1 Reclaiming Space

trimcore/0 reclaims space in all of Prolog's data areas. At any given time, each data area contains some free space. For example, the local stack space contains the local stack and some free space for that stack to grow into. The data area is automatically expanded when it runs out of free space, and it remains expanded until trimcore/0 is called, even though the stack may have shrunk considerably in the meantime. The effect of trimcore/0 is to reduce the free space in all the data areas as much as possible, and to endeavor to give the space no longer needed back to the operating system.

The system property PROLOGKEEPSIZE can be used to define a lower bound on the amount of memory to be retained. Also, the system property PROLOGINITSIZE can be used to request that an initial amount of memory be allocated. This initially allocated memory will not be touched by trimcore/0.

When trimming a given stacks, trimcore/0 will retain at least the amount of space initially allocated for that stack.

trimcore/0 is called each time Prolog returns to the top level or the top of a break level, except it does not trim the stacks then.


Send feedback on this subject.