RFR: 8268078: ClassListParser::_interfaces should be freed [v2]

Yumin Qi minqi at openjdk.java.net
Wed Jun 16 00:49:37 UTC 2021


On Tue, 15 Jun 2021 23:36:15 GMT, Yumin Qi <minqi at openjdk.org> wrote:

>> Calvin Cheung has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   revert the changes for freeing the _id2klass_table
>
> src/hotspot/share/cds/classListParser.cpp line 93:
> 
>> 91:   Atomic::store(&_parsing_thread, (Thread*)NULL);
>> 92:   delete _indy_items;
>> 93:   delete _interfaces;
> 
> In fact below _instance = NULL is not necessary. ClassListParser is a stack object and in ctor, it sets 
> _instance = this;
> So after ClassListParser deallocated from stack, setting it to NULL makes no sense.
> If it is heap object, setting it to NULL could not prevent memory leak.
> Should we remove it?

You can ignore my comment here, It is still useful to set it to NULL:
  static ClassListParser* instance() {
    assert(is_parsing_thread(), "call this only in the thread that created ClassListParsing::_instance");
    assert(_instance != NULL, "must be");
    return _instance;
  }
The static function will check if it is NULL.

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

PR: https://git.openjdk.java.net/jdk/pull/4498


More information about the hotspot-runtime-dev mailing list