Application exit

   6602   2   0
User Avatar
Member
17 posts
Joined: Oct. 2009
Offline
Hi, this question concerns the HDK 10.

I'm looking for a way to perform some resource cleanup at application exit (removing cache files from the hard drive). What is the most efficient way to do this in a SOP node? I've already tried doing it in the destructor, but it seems as it's only called when the node is deleted.

Is there a ‘application exit’ callback function to override? And what happens if houdini crashes - is there a way to free the resources even if I get an ugly segmentation fault ?
Portfolio / Tech. blog: http://www.theprocedure.se [theprocedure.se]
User Avatar
Member
7732 posts
Joined: July 2005
Offline
You should think about why you need to create cache files on disk and their life times. As a user, if a particular SOP node created some files, I probably don't see a reason for them to exist after the node is deleted.

If you must register an exit callback, see UT_Exit::addExitCallback(). These callbacks won't be run when Houdini crashes since any code happening at this time is NOT guaranteed to work anyhow.

If you just need to create some temp files, use UTgetTmpFile() found in UT_TmpDir.h. That will help with the cleanup upon crashing problem.
Edited by - Nov. 5, 2009 22:32:40
User Avatar
Member
17 posts
Joined: Oct. 2009
Offline
edward
You should think about why you need to create cache files on disk and their life times. As a user, if a particular SOP node created some files, I probably don't see a reason for them to exist after the node is deleted.
You are right. My point was that it is not enaugh to do the clean up when the node is deleted. I want to do it both when it is deleted (destructor called) and at application exit (destructor not called, from what I can see).

edward
If you must register an exit callback, see UT_Exit::addExitCallback(). These callbacks won't be run when Houdini crashes since any code happening at this time is guarenteed to work anyhow.

If you just need to create some temp files, use UTgetTmpFile() found in UT_TmpDir.h. That will help with the cleanup upon crashing problem.
I will look into UTgetTmpFile(), sounds very intresting. Thank you very much for the quick answer!
Portfolio / Tech. blog: http://www.theprocedure.se [theprocedure.se]
  • Quick Links