Calling C++ destructor directly in resourceHash.hpp

Thomas Stüfe thomas.stuefe at gmail.com
Mon Jun 12 16:26:06 UTC 2017


On Mon, Jun 12, 2017 at 6:17 PM, Ioi Lam <ioi.lam at oracle.com> wrote:

>
>
> On 6/12/17 12:16 AM, Thomas Stüfe wrote:
>
>
>
> On Mon, Jun 12, 2017 at 7:20 AM, John Rose <john.r.rose at oracle.com> wrote:
>
>> On Jun 11, 2017, at 9:19 PM, Ioi Lam <ioi.lam at oracle.com> wrote:
>> >
>> > I am looking at these two functions in "utilities/resourceHash.hpp":
>>
>> You are worried about the V destructor running,
>> where the V struct is a member of Node (Node::_value).
>> In the normal case, running the destructor of Node
>> transparently runs the destructors of the K and V
>> members of Node.
>>
>> The place where dropped destructors can happen
>> in this sort of pattern is when you overwrite a variable,
>> which is point (a) in your example.  Your V::operator=
>> is responsible for retiring any resources used by the
>> previous value of Node::_value which are not going to
>> be used by the new value.
>>
>> Eventually, when "delete node" happens, whatever
>> resources were in use in Node::_value will be freed.
>>
>> So I don't think you have to do anything with point (b).
>> Your problem, if you have one, is operator=.  Those are
>> hard to get right.
>>
>> — John
>>
>>
> Also, all usages of ResourceHashTable I can see have either primitive data
> types as value type or they do their own cleanup (e.g. Handle in jvmci). Do
> you see any concrete usage where a real object needing destruction is
> placed in a ResourceHashTable?
>
> I am adding a new ResourceHashTable that needs destruction of the stored
> object. And I found out that my destructor is not called.
>
> Thanks
> - Ioi
>
>
Thanks, now I understand the problem.

Kind Regards, Thomas




> ..Thomas
>
>
>


More information about the hotspot-dev mailing list