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$
5
  • $\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$ Commented Apr 7, 2015 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
    Commented Apr 7, 2015 at 0:43
  • $\begingroup$ Just for experimental purposes, what do you get after doing 'Unprotect[In, Out]; Clear[In, Out]'? $\endgroup$
    – ciao
    Commented Apr 7, 2015 at 0:56
  • $\begingroup$ @rasher I actually tried that before. No noticeable change. $\endgroup$
    – anon
    Commented Apr 7, 2015 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
    Commented Apr 7, 2015 at 8:37

1 Answer 1

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$
1
  • $\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
    Commented Apr 7, 2015 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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