Message Boards Message Boards

1
|
358 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Memory leak of coordinate transformation functions

Posted 1 month ago

Hello,
I ran into some functions like "ToPolarCoordinates" that seem not to manage memory usage properly. Compared to "Norm" :

$HistoryLength = 0;
Do[
  ToPolarCoordinates[{x, y, z}];
  Print@MemoryInUse[],
  3];
Do[
  Norm[{x, y, z}];
  Print@MemoryInUse[],
  3];

Out:

96411880
96432720
96453368
96451496
96451496
96451496

I tried other coordinate transformation functions like "ToSphericalCoordinates" and find the same behavoir. Each call to these functions takes extra memory.

And it only occurs to symbolic evaluations. Numerical evaluation is OK:

$HistoryLength = 0;
Do[
  ToPolarCoordinates[{1, 2, 3}];
  Print@MemoryInUse[],
  3];

Out:

96456792
96456792
96456792

Is there some sort of memory leak bug in this behavoir? Tested on MMA 13.3.1.

POSTED BY: Ming XU
2 Replies

I have reported this bug, thank you for bringing it to our attention.

POSTED BY: Jason Biggs
Posted 1 month ago

Thank you. Hope to see the fix with next release. Now I redefine those functions as a workaround.

If possible, please give some hints about how this kind of leak usually happens. Can I avoid it in my program on user level?

POSTED BY: Ming XU
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