423,851 Members | 2,762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

Whenever you exit Python, is all memory de-allocated?

P: 5
Is all memory de-allocated whenever you exit Python?
Oct 30 '18 #1
Share this Question
Share on Google+
2 Replies


P: 5
The answer here is no. The modules with circular references to other objects, or to objects referenced from global namespaces, arenít always freed on exiting Python.

Plus, it is impossible to de-allocate portions of memory reserved by the C library.
Oct 30 '18 #2

P: 1
Yes. This is a more general thing than just Python. With caveats for ancient and embedded operating systems, when a process exits, the kernel reclaims all resources allocated to it.

Now, that may not mean that all memory that the Python process had access to is deallocated. As agrawalanjita pointed out, shared libraries like libc are mapped read-only into the virtual memory space of the process so they don't take up additional space when used by multiple processes. If another process is still using that shared library, it isn't going to be deallocated.
Oct 31 '18 #3

Post your reply

Sign in to post your reply or Sign up for a free account.