LemurPwned / VISM

Software for visualising magnetic layers
Other
6 stars 2 forks source link

Memory freeing #87

Open pawelkulig1 opened 6 years ago

pawelkulig1 commented 6 years ago

I think you haven't checked if function removeDataObject is working. Python has garbage collector that deletes object when there is 0 refs, but another thing is that Python releases this memory when it wants not when we want that. Using del operator for example is considered bad practice. If we truly want to delete some object from mem, we should restart program or, delete all references to object and wait until it's deleted (It may never happen). I don't think there is proper solution for that because Python seems to be smarter. Fortunately it seems that garbage collector is doing good job at runtime end.

LemurPwned commented 6 years ago

Del operator only works if a reference goes out of scope. Reference to an doh objext does not go out of scope until it main window still has doh reference. The only reason for removing function (not object removal) in doh is that the object held in doh should be nullified as soon as it is not used -but still, references to doh should be held. We dont want to destroy doh objects but some of its contents . Obviously overwriting del operator is a bad idea in that case unless we would be in control of object deletion across its references. That is why doh was created to manage references and drop them easily for data structs that are no longer required. Another reason for that is that we dont want to risk the access of invalid data (the data that is still held in doh but is already outdated) About removing object it is true, it happens that I did not return inner funciton that is why it didnt work

Virtually same topic as #56

pawelkulig1 commented 6 years ago

You are right but I doesn't change anything even if you set all this variables to None, memory is not released. Check it with memory profiler.

LemurPwned commented 6 years ago

Right, it doesnt now if the widgets are still running, we are just removing reference from doh which would be still there after widget is destroyed.

pawelkulig1 commented 6 years ago

Closer but still not there :P

pawelkulig1 commented 6 years ago

Of course problem is connected with deleting only reference

LemurPwned commented 6 years ago

What do you mean? I think I dont get it. What I meant is that we merely nullify reference in doh objects not outside. If reference exists outside then it should, but since doh is sort of global it must be cleaned manually, but that doest equal data deletion