RFR: 8316669: ImmutableOopMapSet destructor not called

Jorn Vernee jvernee at openjdk.org
Thu Sep 21 22:35:11 UTC 2023


On Thu, 21 Sep 2023 20:35:41 GMT, Vladimir Kozlov <kvn 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?
>
>> > 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;
}

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

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


More information about the hotspot-compiler-dev mailing list