I have a SystemVerilog class that encapsulates a C++ class using a chandle and the DPI. I want to be sure that the C++ class’s destructor is called when the SystemVerilog object is destroyed. As far as I can tell, this is not being done automatically and I have to manually call the C++ destructor through the DPI when I think that I no longer need the instance. Not very elegant.
Is there a way to specify that certain code should be run for a SV class at GC? Similar to a Java finalize method.