RFR: 8316669: ImmutableOopMapSet destructor not called

Vladimir Kozlov kvn at openjdk.org
Thu Sep 21 22:58:10 UTC 2023


On Thu, 21 Sep 2023 22:30:18 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>>> > Thank you for adding the destructor. It should free memory used by _oop_maps.
>>> 
>>> I can do that, but that would mean that the object would free its own memory it is running on which seems unusal.
>>> 
>>> Maybe it is best to add a static free_oop_map_set or similar method to ImmutableOopMapSet that frees that memory? Then that class would nominally both allocate and deallocate that object's memory.
>>> 
>>> What do you think?
>> 
>> Yes, this should work too. I want ImmutableOopMapSet class handle creation and desctruction instead of Codeblob.
>
> How about implementing an `operator delete(void* p)` on ImmutableOopMapSet? A `delete` expression calls an object's destructor and frees the memory at the same time (memory is freed by calling `operator delete(...)`). The implementation can call `FREE_C_HEAP_ARRAY`, and it avoids CodeBlob needing to call `FREE_C_HEAP_ARRAY` directly.
> 
> 
> static void operator delete(void* ptr) {
>   FREE_C_HEAP_ARRAY(unsigned char, ptr);
> }
> 
> 
> The code here would just become:
> 
> if (_oop_maps != nullptr) {
>   delete _oop_maps;
>   _oop_maps = nullptr;
> }

Yes, I want this!

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15862#discussion_r1333674717


More information about the hotspot-compiler-dev mailing list