2
$\begingroup$

My script generates about 400 objects. If I run the same script twice, I notice the object count remains the same, but the memory allocated does increase substantially.

I thought it was my code (and it may still be), but can someone explain why the following piece of code causes a small (but noticeable) memory leak?

This is after I hold both Alt+P (which runs the script) and I keep my eye on |Mem:11.12M| on top of the blender UI. It increases by .01M every ~5 seconds.

if __name__ == "__main__":
    print('hello')
$\endgroup$
3
$\begingroup$

This does not cause any memory leak. It simply adds entries into your Undo list, and depending on how many undo steps you have setup in preferences the Mem reading will cap out eventually and will not grow any further.

$\endgroup$
  • $\begingroup$ Why would 'print' add items to the undo list? $\endgroup$ – user1798810 Jul 19 '17 at 16:32
  • $\begingroup$ Ran my actual code instead. Each time I execute it, memory keeps increasing. (while # of Objects stays the same). This is after I modified the "Undo" preferences by setting "Steps" to 2 and "Memory Limit" to 1. $\endgroup$ – user1798810 Jul 19 '17 at 16:44
  • $\begingroup$ @user1798810 running the RunScript operator adds this action into the undo list, so everything the script does can be undone. You can check the Undo list by pressing Ctrl-Alt-Z inside 3d view window. It is possible your full script experiences memory leaks, but I don't see this with print("Hello") $\endgroup$ – Jaroslav Jerryno Novotny Jul 20 '17 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.