Calling C++ destructor directly in resourceHash.hpp

Thomas Stüfe thomas.stuefe at
Mon Jun 12 07:16:31 UTC 2017

On Mon, Jun 12, 2017 at 7:20 AM, John Rose <john.r.rose at> wrote:

> On Jun 11, 2017, at 9:19 PM, Ioi Lam <ioi.lam at> 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?


More information about the hotspot-dev mailing list