1
$\begingroup$

I disabled "Show Suggestions Bar after last output" in the preferences. I begin my code with $HistoryLength = 0. After running my code, I run the following.

ClearSystemCache[];
Share[];
Remove["Global`*"];

However, MemoryInUse[] reveals that the kernal still takes up a few gigabytes of memory. What is stored in the kernel? Other than Quit[], what commands can free up most of the memory?

$\endgroup$
  • $\begingroup$ Are you sure that's gigabytes? For me, a fresh kernel starts off with 41254400 bytes, or 39.3 MB. How much data have you generated in expressions between your two code blocks? $\endgroup$ – 2012rcampion Apr 7 '15 at 0:31
  • $\begingroup$ Mine starts with 70577952 bytes, and end with 5100297040 bytes. I do not expect so much memory to be used. Even if there is any memory leak in my code, I have expected the commands in the OP to free up most of the memory. $\endgroup$ – anon Apr 7 '15 at 0:43
  • $\begingroup$ Just for experimental purposes, what do you get after doing 'Unprotect[In, Out]; Clear[In, Out]'? $\endgroup$ – ciao Apr 7 '15 at 0:56
  • $\begingroup$ @rasher I actually tried that before. No noticeable change. $\endgroup$ – anon Apr 7 '15 at 0:57
  • $\begingroup$ I don't know the kernel's architecture so I'm guessing here but I would imagine that the kernel only loads some code and initializes some internal data structures when they're called for. So if your code uses different functions you may end up with different resting memory. If I know I'm going hiking I put my hiking boots in my car, when I get back I probably don't take them out until I clean my car. $\endgroup$ – Ymareth Apr 7 '15 at 8:37
3
$\begingroup$

The large amount of memory used appears to arise from an internal memory leak from MemberQ. Hence, typical methods of clearing the kernel memory do not work as expected in this situation as long as the bug persists.

See: Memory leak in MemberQ

$\endgroup$
  • $\begingroup$ If you're using 10.0.0 or 10.0.1 you should upgrade to 10.0.2 (it's free!) since this bug is fixed there. $\endgroup$ – Stefan R Apr 7 '15 at 21:01

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.