hello,
i have a problem ... i have writen a piece of code do make me an "animated" banner (hiding and showing layers..because every image as a diferente link)... with javascript ...
it works fine... but it has a problem... in about 10 to 15 min time the memory that the PDF uses can go up to 450 megs... an more before it crashes...
the problem is with the function that i use (see code in the end of the message) ...if i turn it of the PDF only uses about 30 megs (and it doesent go up) and stays stable.
can anyone help me with this?
Thanx
///////////////////////////////////////// javascript code
if(theClockTimer)
app.clearInterval(theClockTimer)
var theClockTimer = null;
var zzz = 28;
function roda()
{
var ocgs = this.getOCGs();
for (var i=28; i<31; i++)
ocgs[i].state = false;
ocgs[zzz].state = true;
if (++zzz == 31)
{
zzz = 28;
}
}
app.setInterval("roda();",1000);
roda();
theClockTimer = app.setInterval("roda();",1000);
Since JavaScript does it's own garbage collection there isn't much you can do. And there's nothing obvious that accumulates in your code.
It may be that OCGs are just memory intensive, which makes a bit of sense because they are part of the page content, i.e., they have to be handled with and at the same time as all the other page content, which your script is constantly changing.
You might eliminate the memory problem altogether by putting the images on Button Fields, then rotating them with the "hidden" property.
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script