PhiLho and Koogy, thanks for the help:)
I found out I was generating thousands of shapes, that did not make it to the actual screen. Removing these cleared up the memory issue (but I guess it will return if I actually meant to generate a +5 million shapes picture again).
I moved all the drawing stuff from the draw method and into the setup method. So when running the sketch, I just get everything generated as fast as processing can keep up. i.e. I moved the draing function from the draw method into a for loop in the setup method.
Code:
import processing.pdf.*;
int totalRuns = 600;
ArrayList spores = new ArrayList();
int amount = 5;
void setup()
{
size( 200 * 10, 70 * 10 );
beginRecord(PDF, "everything.pdf");
for( int i = 0; i < amount; i++ )
{
spores.add( new Spore() );
}
for( int j = 0; j < totalRuns; j++ )
{
for( int k = 0; k < amount; k++ )
{
Spore s = (Spore)spores.get( k );
s.step();
}
}
}
void draw()
{
endRecord();
noLoop();
exit();
}
I need a pdf with only vectors shapes, so that I can scale it up. (the Spores class just draws circles when step() is called).
Using beginRecord() endRecord() this way produces really strange results.
The resulting .pdf seems to be a "recording" of each run of the for loop.
So when opening the finished pdf, which is huge ≈ 30 MB using Preview on the Mac, it sort of plays back the drawing of the layers. Meaining that it displays the first spores, then the next and so on. This happens each time I open the pdf or resize it.
How will I draw a lot of circles and have these saved as vector shapes in a pdf, without it grpwing to some crazy size.
I had a graphics dude helping me, he had never seen a pdf behave that way:)
Cheers!
Ps. I found a place (in Denmark) where they will print 200 x 140 cm on 195 grams/square meter paper for £60, day to day print. If you are interested I will check if they have a .com site.