5

Recently, javaw.exe processes have been taking over my computer and forcing me to exit out Eclipse and other applications due to low memory errors. Note that I am not maxing out the system at all, and am I working on some basic java programs, and I have 2-3 eclipse tabs open at a time max.

I have about 40-50 of these javaw.exe processes each take up 22K-26K of RAM, which eventually eats up 70-80% of my 8GB RAM on my machine. This is extremely frustrating as I cannot do any work like this. I was wondering if anyone else has experienced this and knows how to troubleshoot this problem?

AnchovyLegend
  • 12,139
  • 38
  • 147
  • 231

4 Answers4

10

You probably launch the same program again and again from eclipse, and these programs never exit. Switch to the Debug perspective, and look at the Debug view. Kill all the processes that should not run anymore.

That said, 50 * 26KB is very very far from 8GB * 80%. And I doubt any Java program can be as light as 26KB.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 1
    But I do exit these programs. However, when I go to 'Windows Task Manager' the processes don't disappear after I exit the Java programs from eclipse... – AnchovyLegend Oct 08 '12 at 19:31
  • 1
    How do you exit them? Do you press the square red "Terminate" button in the Debug view? A Java program terminates when System.exit() is called. If you just close the main window of your Swing/AWT application, for example, it doesn't exit. – JB Nizet Oct 08 '12 at 19:33
  • 1
    Or it could be that some non-daemon threads continue to run in the background and prevent those programs from exiting. – assylias Oct 08 '12 at 19:38
  • 1
    I see, that is the root of my problem... In the past when I clicked 'x' on java applications it seemed to get rid of the process automatically, however now it is not the case. I will ue the red terminate button from now on... thank you! – AnchovyLegend Oct 08 '12 at 19:40
  • 3
    Or you could fix your program and make sure System.exit is called when the frame is closed. See http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation%28int%29 – JB Nizet Oct 08 '12 at 20:42
  • 2
    Either make a System.exit call when main window is closed or identify background threads that continue running and devise a way to orderly terminate them when main window is closed. When all threads have terminated, the JVM will exit. – Konstantin Komissarchik Oct 08 '12 at 21:34
2

It normally happens when you are doing multi threading. Make sure you stop all the threads which you have created by calling a thread.interrupt() for the the threads you have spawned before you end the application. That would remove javaw.exe from your Task Manager - Hope this will be helpful

Troy Alford
  • 26,660
  • 10
  • 64
  • 82
1

If you are using JFrame, try this:

Main frame=new Main();//Main class extends JFrame.
frame.setdefaultcloseoperation(JFrame.EXIT_ON_CLOSE);
Robert Rouhani
  • 14,512
  • 6
  • 44
  • 59
hanif_cool
  • 11
  • 1
0

Normally each eclipse instance should only have one javaw.exe process.. so check with a process explorer that they actually belong to eclipse and not some other background/zombie programs.

If you want to reduce javaw.exe memory, you can use Help -> Performance -> Reducy Memory now..

Note that this will reduce the used memory only of the actual eclipse's javaw.exe process..

Majid Laissi
  • 19,188
  • 19
  • 68
  • 105