|
Hi Aaron,On the iSeries while starting a java app you can specify the initial heap size. So issuing a command such as 'java Xms6m MyClass' will launch your app and set the initial heap size to 6mb. Strictly speaking this is the initial heap size, but it is used as the GC threshold. Thus, once enough objects to consume 6mb of memory have been created by your app the GC will automatically start. Once GC has completed, if another 6mb of memory is consumed by object creation the GC will start again.
Basically, a low initial heap size will cause GC to run more frequently and will keep your heap smaller. A higher initial heap size will cause GC to run less frequently, and the heap will grow larger. However, when GC does run it will run longer as the object scan will take more time to complete (more objects to check).
If you set the maximum heap size (using 'java Xmx15m MyClass') then your app can not have a heap that exceeds 15mb of memory. If you attempt to create a new object and the maximum heap size would be exceeded then the GC will run synchronously - to attempt to free some memory for you. If it can't then your app will recieve a java.lang.OutOfMemory exception.
Although you're not running your code on an iSeries (I think), maybe you could try to play with these values when starting your app. You may find a good value which forces GC to run frequently enough for you on the system you are using.
Cheers Larry Ducie
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.