java.lang.OutOfMemoryError

User 870ab5b546

29-11-2005 16:22:38

A student running Safari 2.0 on MacOS 10.4.3 has shown me that after ACE reloads Marvin 10-20 times, ACE slows down, and she soon gets this error:





Molfile cannot be loaded because an error occurred:


java.lang.OutOfMemoryError





#10101





Do you have any idea what would cause this error message to be generated, and how it can be prevented?





I don't know whether it would help, but I'm attaching four files that generate the page in question.

ChemAxon 7c2d26e5cf

29-11-2005 20:21:09

Currently, we can not test it because we haven't got this OS X version. But we plan to by a new Apple machine to be able to test OS X 10.4.





Have you managed to reproduce this out of memory error on another machine with another OS X (or another operating system) using a different Java version?

User 870ab5b546

30-11-2005 00:14:22

This is the first report I've had of this problem in the student response section of ACE. But few students use Macs.





We've had this problem all along in the authoring section of ACE. But we attributed that to the fact that we open a new window every time MarvinSketch is launched. That's not the case now.

ChemAxon 7c2d26e5cf

01-12-2005 15:20:55

Quote:
We've had this problem all along in the authoring section of ACE. But we attributed that to the fact that we open a new window every time MarvinSketch is launched. That's not the case now.
Normally, detaching a MarvinSketch window from a Marvin applet should not cause an out of memory error. Is this error reproducable with only the new OS X version?


Have you managed to reproduce this error with any Marvin applets example from the ChemAxon site? http://www.chemaxon.com/marvin/doc/dev/index.html#examples

User 870ab5b546

01-12-2005 16:36:59

I don't understand your terminology about "detaching a MarvinSketch window from a Marvin applet". The longstanding problem is as follows. We open a new browser window which contains MarvinSketch. MarvinSketch loads, initiates, starts. We draw a structure and press the Submit button. The window closes. Then, we repeat. After 10-20 times, MarvinSketch begins to load slowly, then gives an out of memory error, and then, if we persist in authoring, it eventually hangs during load. At that point we have to quit the browser and restart. This has been going on for three years. It happens on all platforms and browsers, AFAIK.





But, in the new problem, all the action is going on in a single browser window. In such a case, we've never before seen MarvinSketch slow down and then hang. Never heard any complaint about it, either, until now.

ChemAxon 7c2d26e5cf

02-12-2005 13:04:37

Quote:
I don't understand your terminology about "detaching a MarvinSketch window from a Marvin applet"
I misunderstood your previous comment. I believed you talk about the MarvinSketch popup frame which you open from a MarvinSketch applet, not about the browser window. Now, I am already understand what you talk about.
Quote:
We open a new browser window which contains MarvinSketch. MarvinSketch loads, initiates, starts. We draw a structure and press the Submit button. The window closes.Then, we repeat. After 10-20 times, MarvinSketch begins to load slowly, then gives an out of memory error, and then, if we persist in authoring, it eventually hangs during load. At that point we have to quit the browser and restart. This has been going on for three years. It happens on all platforms and browsers, AFAIK.
It is clear that your Java is run out of the memory when you use your MarvinSketch applet. But I have not still managed to find an example where I can reproduce this memory error with the current Marvin.





For debugging the problem we need the followings:


- A detailed scenario how you can reproduce memory error. Please include any recurring actions (e.g.: button press, shortcuts) which might lead to the error.


- A simple self-contained html example where this error is occurred.


- Description of the software environment where the error is reproducible: operating system type, Java version, Marvin version, browser type/version.





The simple self-contained html example would be very important because it is possible the problem in the JavaScript code.


By the way, we know about a bug in Java 1.4.2 which may cause memory leak if you use JavaScript but it is a Linux specific issue:


http://www.chemaxon.com/marvin/doc/bugs/faq.html (see the last point in the Browser crashes section).

ChemAxon 587f88acea

22-02-2006 15:07:10

Hi Tamas,





I was hoping the upgrade to Marvin 4.0 would fix the problem, but it hasn't.





What is a "self-contained" HTML example?





-- Bob

ChemAxon 587f88acea

22-02-2006 15:36:48

Here are some specific instructions for generating the problem. I am using Marvin 4.0.3, Java 1.4.2_09, Safari 1.3.2, Mac OS 10.3.9, iMac G4.





Log in to http://epoch.chem.uky.edu under the username and password I will send you under separate cover.


Click on Test course.


Choose the Question Bank tab.


Choose Test Problems and Bob's problems from the two popup menus.


Click the Edit icon next to question 2.


Click the Edit icon next to the wrong answer. A page containing Marvin 4.0.3 will pop up. If the top frame fails to load, refresh the page.


Press the OK button.


Repeat the previous two steps many times. It took me about 25 reloads of the edit-condition page before I started seeing slower loads of Marvin.

ChemAxon 7c2d26e5cf

27-02-2006 23:33:13

Hi Bob,


There may be some problem with your server because I have not found the login page on your site. The above link refers to the Tomcat's welcome page.


Tamas

ChemAxon 587f88acea

28-02-2006 00:22:19

Oops. http://epoch.chem.uky.edu/lite .

ChemAxon 7c2d26e5cf

07-03-2006 19:08:17

Hi Bob,


I would rather continue this chat in email.

User fd011f540e

05-06-2006 18:16:01

Tamas wrote:
Hi Bob,


I would rather continue this chat in email.
For those of us that are experiencing the same issue and are not part of your email thread, have you identified a cause, fix or workaround?

User 870ab5b546

05-06-2006 19:36:10

You mean, I am not the only one experiencing this problem? That's good to know; maybe the issue will rise higher on the radar screen at ChemAxon.





We have not yet found a workaround or solution. I can use the Java console to watch the memory use increase each time I reload this one particular page. The Java console is supposed to show occasionally that the MarvinSketch thread is terminated (I forget the exact language), and it does show it on other pages, but it does not ever show it on this particular page. Eventually the memory use reaches 64K, and the applet quits functioning.





Tamas suspects that it does not terminate because the program is still pointing to that MarvinSketch thread from somewhere else, but we cannot imagine where that could be. That's as far as we've made progress. Tamas was supposed to delve deeper into our program to see if his suspicion is correct, but he has not found the time to do it.

User fd011f540e

05-06-2006 21:26:53

bobgr wrote:
You mean, I am not the only one experiencing this problem? That's good to know; maybe the issue will rise higher on the radar screen at ChemAxon.





-snip-





Tamas suspects that it does not terminate because the program is still pointing to that MarvinSketch thread from somewhere else, but we cannot imagine where that could be. That's as far as we've made progress. Tamas was supposed to delve deeper into our program to see if his suspicion is correct, but he has not found the time to do it.
This is a major headache for a project that I am working on. We see a 5 megabyte increase in the browser memory partition every time we use the plugin to generate a structure to search for. The memory is never released. They continue to say it is our code, but they cannot identify what it is we are doing wrong. It seems to me that their code should be releasing the memory allocated when their routines finish. This happens in all browsers on both Mac and PC platforms.

ChemAxon 7c2d26e5cf

06-06-2006 13:40:20

Can you give me a detailed description about your PC and Mac platforms (operating system, java version, browser type, Marvin version) where you have got the same problem than in Bob's example? If you can send an example, I could compare it with Bob's code. Probably, it is help to debug both issues.


If above information would be confidential and you don't want to share your example with other ones, just drop an email to our support email address ( I will answer for you).

User 870ab5b546

06-06-2006 14:11:22

In another part of our code, where we usually do not see the out of memory errors, when I watch the Java console for memory usage, I see the memory being released only when I go *back into* the MarvinSketch page.





In the page on which we do generate the out of memory errors, the name of the page is often different because of parameters that are passed through the URL. However, even if I go back to the page with the exact same URL, memory is not released.





I hope this information helps.





Tamas, you have full read capabilities on our server at epoch.chem.uky.edu. Feel free to rummage around.





See you tonight.

ChemAxon 7c2d26e5cf

06-06-2006 14:36:09

OK, I will be there.

User 05a0a0ba3d

07-06-2006 17:48:36

Attached are two files:





1. memleak.html – contains HTML code that uses the MSketch applet.


2. ChemaxonMemLeak.xls – contains data collected while running memleak.html through the memory profiler AppPerfect.





During this profile, I used the applet previewer sun.applet.AppletViewer.


I started MSketch 3 times during the profile; before the 2nd and 3rd instances of MSketch, the applet was destroyed.





The spreadsheet ChemaxonMemLeak.xls shows unequivocally that


there is a memory leak in the ChemAxon software. In particular, it


appears that instancs of these objects are never released:





chemaxon.struc.CEdge[]


chemaxon.struc.CNode[]


chemaxon.struc.MolAtom


chemaxon.struc.Molecule


chemaxon.struc.RgMolecule





Additionally, there may be some objects from java.lang which


are not released.





Tamas, you may want to look at the MSketch destruction code


and make sure all lingering object references – including those


appearing in Hashtables – are released.

User f359e526a1

09-06-2006 07:45:08

Thanks! It certainly must be solved.

User 870ab5b546

22-06-2006 16:10:40

Here's another jsp page that may help you diagnose this problem:





http://epoch.chem.uky.edu/epoch-plugin/authortool/comparetwo.jsp





The page is very stand-alone. It loads two Marvin applets. I've noticed that after 5-8 submissions, the applets start to crash and the page ceases to load. The only solution is to quit Safari or Netscape.

ChemAxon 7c2d26e5cf

22-06-2006 18:56:22

Thanks for the newer example. I am investigating the memory issue.

User 870ab5b546

28-08-2006 15:26:07

I hesitate to proclaim victory, but it appears that the memory leak problem is solved in Marvin 4.1.

ChemAxon 7c2d26e5cf

29-08-2006 10:02:34

Yes, I have fixed potential memory leaks in applets in Marvin 4.1.

User 05a0a0ba3d

29-08-2006 21:06:18

Before, we observed that one applet (MSketch) triggered


a linear increase in memory consumption in the browser;


the leakage was roughly on the order of 3 MB for every


applet refresh.





What I have verified is that both FireFox and Internet Explorer


both stabilize with heap allocation around 55-60 MB as the


MSketch applet (running against Marvin 4.1 Alpha) is refreshed.


This represents a significant improvement over the original


test scenario I posted.





However, we still are observing leakage when the applet


runs within the context of our application. It certainly could


be a leakage issue on our side, but my preliminary analysis


suggests there continues to be some leakage in Marvin 4.1 Alpha.


I emphasize that this is *preliminary*. I must do more


analysis to find out exactly what conditions are triggering the


leakage.





In summary, we have observed a signficant improvement,


but leakage in some form still persists, although I am not


yet 100% certain that leakage is in Marvin or not.





Charlie

User 05a0a0ba3d

13-09-2006 21:44:46

The attached data (in Excel) unequivocably demonstrates


that a memory leak persists in the MSketch applet. This data


was gathered from the memory profiler AppPerfect on 09-13-2006,


running the MSketch applet within a stand-alone HTML page rendered


in Sun's AppletViewer.





The data suggests that the leakage is occuring in UI components


in MSketch. The objects that show a marked increase in size with


each Applet-Restart are:





javax.swing.JMenu


javax.swing.JMenuItem


java.lang.Object[]





Because several collections (HashMap, Arrays, etc) are also


live when observing the increased memory demand made


by these objects, I would suggest that the leakage might be


occurring within some UI component that never clears some


kind of internal collection at time of destruction. (But this is just


a guess, because I have never seen the Chemaxon software.)





Charlie

User 05a0a0ba3d

13-09-2006 21:48:06

I used the attached HTML page to profile MSketch from within AppPerfect.





Charlie

ChemAxon 7c2d26e5cf

14-09-2006 23:26:15

Thanks for the files. I will check UI components.

User 05a0a0ba3d

20-09-2006 14:03:45

I did a little more profiling in AppPerfect – running the MSketch applet


through 10 refresh cycles (rather than just 4 as my previous


forums-posting indicated) – and the memory profile indicates


that there IS NOT a memory leak incurred during the applet refreshes.





This is not to say we are not running into some memory issue;


indeed, we are. It may have more to do with Firefox internals.


We still are not sure.





Thanks for your investigations in this matter. As always,


we appreciate your attention to our questions.