cache memory release

31 views
Skip to first unread message

Zhian

unread,
Nov 25, 2024, 2:26:24 AM11/25/24
to OpenVDB Forum
I am running multiple threads of independent computations with each thread containing a local copy of grid which keeps being created and deleted.   However we found that the memory usage keeps increasing and when we create and release new grids.   We are suspecting that this is due to the use cache memory.     We found that by calling "initialize()" and "uninitialize()" each time we create and release a grid we can solve this problem.   But I am wondering is this is safe to do since both of these are global static functions.   I wonder if this can affect computations in other threads.       
So far this is working.  Just wondering if there is a safer way of clearing the cache memory.  
Thanks,

Zhian

edward

unread,
Nov 25, 2024, 9:24:20 AM11/25/24
to OpenVDB Forum
Offhand, I can't imagine anything that should leak if you're just creating and modifying grids. I thought initialize/uninitialize functions are supposed to just manage one time registrations. I don't feel that it's safe to initialize()/uninitialize() from multiple threads either. While they're serialized against each other (which means performance bottleneck to begin with), I'd imagine that anything trying to use those global registries will fail. My first suspicion would be that this is not a real leak because some allocators will hold on to memory that's been released by the application but not necessarily return it to the system. However, I don't have any explanation as to why you can fix this by uninitializing.  I'd suggest trying to reproduce with a small example and logging it on github so that a closer look can be made. Maybe there's something obvious about the way you're doing things.

Cheers,
-Edward

Zhian

unread,
Nov 29, 2024, 10:46:38 PM11/29/24
to OpenVDB Forum
After I call the clear() method I also called the memUsage() function and it showed that the memory usage is reduced to almost zero.   But from top command the memory usage keeps increasing and in the end the system will crash,  unless I  used the uninitialize() call.   I will try to make a example program to show this.
Thanks
Zhian
Reply all
Reply to author
Forward
0 new messages