Copy link to clipboard
Copied
Hi,
I'm running into memory problems and am looking for some advice.
I run a double tight for-loop in which I draw thousands of shapes. While the for-loops are active I notice that memory is being consumed quickly. When I stop the drawing process and with the resulting Illustrator file still open, I see memory usage fall significantly, back to normal levels. This makes me suspect that it is not the resulting drawing that is consuming memory but the variables I use in the loops. It feels as if garbage collection isn't working properly: as if variables that go out of scopes are not released for cleanup.
I there anything I can/should do about this? I already do a 'save as' action at the end of each inner loop. Should I bring all variables outside of the loops? Should I nullify them?
Any help greatly appreciated.
// Tom
for (var i = 0; i < kNumRows; i++) {
for (var j = 0; j < kNumCols; j++) {
// I use a lot of local variables here
}
// saveas action
}
awesome, that's what's usually adviced, taking variable declarations outside of loops does help.
Copy link to clipboard
Copied
that's a known problem in Illustrator, garbage collection doesn't work. The longer you work with it manually or automatically the slower is gets.
you have to restart illustrator to release memory.
can you post some of your code inside the loops?
Copy link to clipboard
Copied
Hi Carlos,
Many thanks for your reaction. I think I may have solved my problem. Well, not really solved it but it's a work around for a memory leak: I simply declared all variables that are used within the loops outside of the loops. So new values get assigned on every iteration of the loop but the reserved memory locations stay the same (I presume). Not so elegant, counter to good programming practice, I believe, but it works.
Oh, and how I wish it was faster...
Copy link to clipboard
Copied
awesome, that's what's usually adviced, taking variable declarations outside of loops does help.