Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to manage memory? #31

Open
tpwrules opened this issue Sep 20, 2021 · 4 comments
Open

How to manage memory? #31

tpwrules opened this issue Sep 20, 2021 · 4 comments

Comments

@tpwrules
Copy link

I have a simple script which loads a bunch of files using pycc.FileIOFilter.LoadFromFile, but I cannot figure out how to destroy the ccHObjects that it returns. Thus, the loaded files are simply leaked and CloudCompare eventually crashes because it runs out of memory.

I also cannot figure out how to remove objects that have been added to the DB, or how (or if) I should destroy the clouds returned from methods like resampleCloudSpatially, partialClone, etc.

I think there needs to be a section on memory management in the documentation, and perhaps some additional methods added if necessary. I don't think it's possible to correctly manage memory right now.

@tmontaigu
Copy link
Owner

The memory management is the same as regular Python so you should not have to care about about deleting/destroying objects.

The fact that pycc.FileIOFilter.LoadFromFile leaked memory was due to leftovers from a time where memory management was unclear with the DB.

And the removeFromDB method was added to the ccGUIPythonInstance API.

The master branch contains the fixes.

@tpwrules
Copy link
Author

Memory management still does not quite work with ccHObject. Consider the following code:

file = pycc.FileIOFilter.LoadFromFile(path, params)
obj = file.getChild(0)
del file

subsampled = cccorelib.CloudSamplingTools.resampleCloudSpatially(obj, 0.001, mod_params)

CloudCompare crashes at the last line because del file destroyed the child obj while Python still had a reference to it.

@tmontaigu
Copy link
Owner

tmontaigu commented Sep 21, 2021

the plugin is still very experimental so not all things are not going to work flawlessly.

This case may be fixable

In the meantime, you can just remove that del

@tmontaigu
Copy link
Owner

tmontaigu commented Sep 22, 2021

Fixing this required a bit more work that I initially thought, but it should work now.

I expect some other similar case to exist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants