You can set the PB_POOL_THRESHOLD environment variable to specify the threshold at which the PowerBuilder memory manager switches to a different memory allocation strategy.
When most windows, DataWindows, DataStores, or other PowerBuilder objects are destroyed or reclaimed by the garbage collector, the PowerBuilder heap manager returns the memory allocated for each object to a global memory pool and records its availability on a global free list. The freed memory is not returned to the operating system. When a new object is created, PowerBuilder allocates blocks of memory from the global memory pool (if sufficient memory is available in the global free list) or from the operating system (if it is not) to a memory pool for the object.
When the memory required by an object exceeds 256KB, PowerBuilder uses a different strategy. It allocates subsequent memory requirements from the operating system in large blocks, and returns the physical memory to the operating system when the object is destroyed. It retains the virtual memory to reduce fragmentation of the virtual address space.
For most applications and components, the threshold of 256KB at which PowerBuilder switches to the “large blocks” strategy works well and reduces the memory required by an application when it is working at its peak level of activity. However, if you want to keep the overall physical memory usage of your application as low as possible, you can try setting a lower threshold.
The advantage of setting a low threshold is that the size of the global memory pool is reduced. The application does not retain a lot of memory when it is inactive. The disadvantage is that large blocks of memory are allocated for objects that require more memory than the threshold value, so that when the application is running at its peak of activity, it might use more virtual memory than it would with the default threshold.
Setting a low threshold can be beneficial for long-running client applications that use many short-lived objects, where the client application’s memory usage varies from low (when idle) to high (when active). For multithreaded applications, such as servers, a higher threshold usually results in lower virtual memory utilization.
You can record diagnostic ouput from the PowerBuilder heap manager in a file to help you troubleshoot memory allocation issues in your application. The PB_HEAP_LOGFILENAME environment variable specifies the name and location of the file.
If you specify a file name but not a directory, the file is saved in the same directory as the PowerBuilder executable, or, for a PowerBuilder component running on EAServer, to the EAServer bin directory.
If you specify a directory that does not exist, the file is not created, or, for a PowerBuilder component running on EAServer, output is written to the EAServer log file (Jaguar.log).
By default, the log file is overwritten when you restart PowerBuilder or EAServer. If you want diagnostic output to be appended to the file, set PB_HEAP_LOGFILE_OVERWRITE to false.
You can set the variables in a batch file that launches the application, or as system or user environment variables on the computer or server on which the application or component runs.
For more information about tuning memory management in PowerBuilder and EAServer, see the technical document EAServer/PowerBuilder Memory Tuning and Troubleshooting.