This content has been marked as final. Show 3 replies
gn_164 wrote:This is a known bug with the memory counters. Logically the scope is reclaimed when the last thread leaves, but in practice actual reclaiming is deferred until the next thread enters. The memory counters should have been adjusted when the thread left, but they weren't. If you check the available memory each time you enter the scope you will see that the full amount is available each time.
I am working with RTS on eclipse, I have written a simple program where i construct a LTMemory object and i print its memoryRemaining() method once before entering the scope and once after exiting the scope.(Inside the scope i allocated two Integer objects) The memory doesn't seem to be reclaimed.
Furthermore i get the same number of bytes from the first call of the memoryRemaining() (16384) irrelative to the number i pass at the constructor of the LTMemory object.The VM has a default minimum scope size of 16KB. You can change this by using the -XX:ScopedMemoryAllocGrain=n flag where n is the number of bytes: 512, 1K, 1M. Only use a power-of-2 because the actual size will be rounded down to the closest power of 2.
I see this flag is missing from our command-line options documentation.
another short question:
... where n is the number of bytes: 512, 1K, 1M. Only use a power-of-2 because the actual size will be rounded down to the closest power of 2.Does this apply also to other VM options where a memory size is specified (like -XX:ScopedSize, -XX:ImmortalSize)? Does it apply also if I allocate scoped memory in my application (like ScopedMemory sm = new LTMemory(20000) -> is rounded down to 16384 (next lower power-of-2 value))?
The size passed to the Java-level constructor is rounded up to a ScopedMemoryAllocGrain multiple.
The values given for -XX:ScopedSize and -XX:ImmortalSize are rounded up to a value related to the page size - which is around 8K on the main platforms. Also the ScopedSize is doubled as the VM uses the double-buffering scheme internally,