MemorySegment JVM memory leak

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Thu Apr 23 00:48:27 UTC 2020


On 23/04/2020 01:34, Maurizio Cimadamore wrote:
> No. But that doesn't seem to be a very important issue? If you don't 
> need the original safe segment, you can just ditch it and leave it to 
> the GC? 

Ok, I see what you mean now.

You basically want that calling close() on the unsafe segment calls the 
cleanup action (unmap) of the original segment. And, it seems you don't 
want to write native code for it either, so you have no way to write a 
Runnable that does what you want.

When I issued the patch originally, I allowed the possibility of passing 
an AutoCloseable as a cleanup action (not a Runnable), which meant you 
could pass the _safe_ segment as the cleanup action, and the cleanup 
action would have been called regardless of confinement.

During the review process, it was observed that this was perhaps a bit 
too magic - e.g. calling close() would leave the original segment in an 
unconsistent state (e.g. isAlive() == true, but memory freed).

I'll think a bit more whether something like that could be achieved in a 
way that doesn't add too much complexity to the API, I think I see maybe 
a path to get there (or maybe is the late hour :-) ).

Thanks
Maurizio



More information about the panama-dev mailing list