Message Boards Message Boards

1
|
13533 Views
|
11 Replies
|
3 Total Likes
View groups...
Share
Share this post:

What options does Mathematica have for memory management?

Posted 10 years ago
POSTED BY: Jonatan Lehtonen
11 Replies
POSTED BY: Jeffrey Saltzman
Posted 9 years ago
POSTED BY: RICHARD WEIMER

Mathematica uses reference counting rather than garbage collection in order to determine what memory can be recycled.

POSTED BY: Daniel Lichtblau
Attachments:
POSTED BY: Jeffrey Saltzman

I finally had the time to do some additional checking, and found that even this seemingly harmless minimal example eats ~43 KB of memory every time you run it, with seemingly no way of clearing up that memory.

Remove["Global`*"];
ClearSystemCache[];
$HistoryLength = 0;
Share[];
MemoryInUse[]
Needs["NDSolve`FEM`"];
region = Rectangle[{0, 0}, {1, 1}];
op = Laplacian[u[x, y], {x, y}];
dirichlet = {DirichletCondition[u[x, y] == 0, x == 1], 
   DirichletCondition[u[x, y] == 1, x == 0]};
uif = NDSolveValue[{op == 0, dirichlet}, u, {x, y} \[Element] region];

Could someone with Mathematica 10 (required for NDSolve`FEM) try this out and see if the same happens for them? Just paste it into a notebook, run it a few times until the memory usage "stabilizes" (first three runs or so the memory usage is all over the place), and then see if the memory consumption consistently goes up.

In fact, just calling the first six lines (i.e. up to and including the Needs-statement) seems to suck up 1 KB of memory every time it's run.

P.S. Just to clarify, I know 43 KB seems like a small amount, but keep in mind that this is a minimal example. In my actual work, I'm seeing memory leakage of up to 2 GB in as little as an hour.

P.P.S. Before you ask: yes, I'll make a bug report about this soon unless someone finds a miracle cure for it. I just want to check if the issue is replicateable before I send the report.

POSTED BY: Jonatan Lehtonen

Reported/confirmed as a bug.

POSTED BY: Daniel Lichtblau

Thank you for confirming this, I've contacted support now.

POSTED BY: Jonatan Lehtonen

You can add Share[] to your list to see if it has any effect....

POSTED BY: David Reiss

I tried this, but the effect was very minor, a mere 2% decrease in memory usage.

POSTED BY: Jonatan Lehtonen

You might want to send an example to support@wolfram.com. The description you give is not inconsistent with an actual memory leak).(I use a double negative by intent; I do not want to give the impression that this is necessarily indicative of a bug, just that it is a possibility).

POSTED BY: Daniel Lichtblau

Thanks, that's probably my next step unless someone points out something I've missed.

POSTED BY: Jonatan Lehtonen
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract