Mathematica 9 is now available
Student Support Forum
Student Support Forum: 'Memory optimization' topicStudent Support Forum > General > Archives > "Memory optimization"

Next Comment >Help | Reply To Topic
Author Comment/Response
01/09/12 6:10pm


I wrote a Sierpinski triangle algorithm for a computer science class and I've got a problem with it. Actually, it uses 200 MB of memory per run and this memory is not freed, so I'm somewhat constrained to a limited number of points due to this memory limitation.

The code is the following:
Sierp[N_, x0_: 0.5, y0_: 0.5] :=
Module[{nmax = N, n, P, list}, Subscript[P, 0] = {x0, y0}; n = 1;
Subscript[list, 0] = startlist;
Do[Evaluate [
Subscript[P, n] =
1/2 (startlist[[throwd3[]]] + Subscript[P, n - 1])];
Subscript[list, n] =
Append[Subscript[list, (n - 1)], Subscript[P, n]], {n, nmax}];
ListPlot[Subscript[list, nmax], PlotStyle -> PointSize[0.0001]]]

Basically, if I remove P and list from the Module variables, the memory does not add up anymore, nonetheless the variables are still stored, although I do not need to keep them saved...

Thanks for any ideas!

URL: ,

Subject (listing for 'Memory optimization')
Author Date Posted
Memory optimization Wojtek 01/09/12 6:10pm
Re: Memory optimization Nasser M. Ab... 01/11/12 11:05pm
Next Comment >Help | Reply To Topic