These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Memory problem - how can i clean it ?

vitors
Registered: Mar 17 2008
Posts: 5

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);

My Product Information:
Acrobat Pro 8.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Why do you set the timer twice? This could contribute to a memory problem

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