Calling C++ destructor directly in resourceHash.hpp
john.r.rose at oracle.com
Mon Jun 12 05:20:31 UTC 2017
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.
More information about the hotspot-dev