Philip wrote:

> PROBLEM:  I am a Mac user. (That is NOT the problem!!)

uhhh ... no comment ... ;-)

> In safari I am
> running into a memory leak, I think.  If I run the page many times
> (hitting the "new problem" button), I can eventually get cpu usage up
> to the max and Safari hangs.  Now this takes 30-40 iterations.   But,
> I  have seen students sit at the computer for hours doing tutorials
> like  this, so 30-40 problems will not be at all unusual.  This raises
> some  questions for me.
>
> 1. Is the fault of the applet?  I don't think so since it seems to run
>  on Windows browsers without the problem -- though I would like
> confirmation of that.

While it is possible that the problem is with the applet, I don't think
so.

I just went to your page and hit the 'new problem' button on linux 100
times. Java consumption went up from approx 2.5 Mb to approx 4 Mb. I
frankly don't know why it went up at all.

But clearly there is something worse going on with Safari.

> 2. Is it the fault of my code?  A good possibility.  If so, is there a
>  way to "clear memory" without removing the applet after each problem?

OK, I just looked at your source code. I have a theory as to what is going
on. If you are interested in the details, see below*.

Every time "New Problem" is pressed you are calling a JavaScript function
setApplets(). setApplets() is resetting the innerHTML property. This is
effectively forcing a reload of the applet. This is, frankly, a rather
strange behavior for an applet. Hence the safari bug.

There is no reason to reload the applet. Rather, you can keep the same
applet loaded and ask it to load a new model.

You can make the script call:
  document.jmol1.script("load oneNewModel");
  document.jmol2.script("load theOtherNewModel");

Where "jmol1" and "jmol2" are the names of the two applets. (That is
another problem with your code today ... both applets have the same name
... name="jMol"

This will reuse the same applet rather than launching a new one each time.

In addition, it should be much faster ... and a smoother user experience.


> 3. Is it the fault of Safari?  I have no control over that :(.

see my theory below.

> If the applet is loaded for the first problem, I was under the
> impression it is not reloaded for each successive one; it knows it is
> there; it is simply refreshed with new data.  Is that correct?

Well, it *would* be correct, except they JavaScript code is explicitly
creating a new applet each time that New Problem is pressed.

> If
> not, is there a way to make it so?  That is, I do not want to be
> loading up memory with multiple unused copies of the applet.

Correct!

> Phil

Tell your JavaScript assistant to write me if he/she has any questions.


Miguel





-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Jmol-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to