OutOfMemory Exception?

Status
Nicht offen für weitere Antworten.

Mic

Mitglied
I would appreciate some help regarding Java's memory model.

At times I get
Code:
java.lang.OutOfMemoryError: unable to create new native thread
        at java.lang.Thread.start0(Native Method)
        at java.lang.Thread.start(Thread.java:574)
        at org.apache.commons.httpclient.util.TimeoutController.execute(TimeoutController.java:61)
        at org.apache.commons.httpclient.util.TimeoutController.execute(TimeoutController.java:82)
        at org.apache.commons.httpclient.protocol.ControllerThreadSocketFactory.createSocket(ControllerThreadSocketFactory.java:95)
        at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:128)
        at wora.service.access.http.MeasurementProtocolSocketFactory.createSocket(MeasurementProtocolSocketFactory.java:61)
There I am creating a new socket for my http client:

Java:
     public Socket createSocket(final String host, final int port,
			final InetAddress localAddress, final int localPort,
			final HttpConnectionParams params) throws IOException {
		startTime.set(System.currentTimeMillis());
		Socket socket;
		try {
			socket = delegate.createSocket(host, port, localAddress, localPort,
					params);
			return socket;
		} catch (OutOfMemoryError e) {
			ServerHealthBacking.logIt();
			throw (e);
		}
	}

As you can see above I already introduced some logging when this OutOfMemory occurs. The memory looks like this at that point of time:

Code:
heap: init = 0(0K) used = 28684528(28012K) committed = 45522944(44456K) max = 166526976(162624K) commited usage=63% max usage=17%
non heap: init = 8552448(8352K) used = 41372552(40402K) committed = 42303488(41312K) max = 100663296(98304K) commited usage=97% max usage=41%

Code Cache - NOW : init = 163840(160K) used = 6639296(6483K) committed = 6651904(6496K) max = 33554432(32768K) commited usage=99% max usage=19%
Code Cache - COLLECTION : null
Eden Space - NOW : init = 524288(512K) used = 1419056(1385K) committed = 2949120(2880K) max = 10354688(10112K) commited usage=48% max usage=13%
Eden Space - COLLECTION : init = 524288(512K) used = 0(0K) committed = 2949120(2880K) max = 10354688(10112K) commited usage=0% max usage=0%
Survivor Space - NOW : init = 65536(64K) used = 67472(65K) committed = 327680(320K) max = 1245184(1216K) commited usage=20% max usage=5%
Survivor Space - COLLECTION : init = 65536(64K) used = 67472(65K) committed = 327680(320K) max = 1245184(1216K) commited usage=20% max usage=5%
Tenured Gen - NOW : init = 1441792(1408K) used = 27198000(26560K) committed = 42246144(41256K) max = 154927104(151296K) commited usage=64% max usage=1
7%
Tenured Gen - COLLECTION : init = 1441792(1408K) used = 16836616(16442K) committed = 28061696(27404K) max = 154927104(151296K) commited usage=59% max
usage=10%
Perm Gen - NOW : init = 8388608(8192K) used = 34733256(33919K) committed = 35651584(34816K) max = 67108864(65536K) commited usage=97% max usage=51%
Perm Gen - COLLECTION : init = 8388608(8192K) used = 33552040(32765K) committed = 33554432(32768K) max = 67108864(65536K) commited usage=99% max usage
=49%

So I am not really a professional regarding Java's memory model, but why does the VM not just increase the commited space since max space is not full?

Are there any tuning options instead of increasing the total memory, which is not an option in my case?

Thanks for your help!
Michael
 
Zuletzt bearbeitet von einem Moderator:
M

maki

Gast
You should never catch an Error unless you know exactly what you are doing.

Do you know how many Threads you're actually starting before you get the OOME?
 

Mic

Mitglied
You should never catch an Error unless you know exactly what you are doing.

Do you know how many Threads you're actually starting before you get the OOME?

I tend to believe that I know what I am doing, especially as I am throwing that catched exception again.

thread count=86, daemon threads=74, peak=88, total started=10381

Maybe one interesting point is that the exception does not occur at times of high traffic on my portal. Tomcat's number of used threads has been at 2 at that time while it is at 50 at other times and no exception does occur.
 
Zuletzt bearbeitet:
M

maki

Gast
Sounds funny, but this special kind of OOME (unable to create new native thread) can indicate that your VM is too big, leaving not enough resources for the OS.

Maybe you could try to reduce the VM Memory and check if you're able to start more threads than before.
 

Mic

Mitglied
Sounds funny, but this special kind of OOME (unable to create new native thread) can indicate that your VM is too big, leaving not enough resources for the OS.

Maybe you could try to reduce the VM Memory and check if you're able to start more threads than before.

:)

At the moment it looks like this...

# free
total used free shared buffers cached
Mem: 1048576 833156 215420 0 0 0
-/+ buffers/cache: 833156 215420
Swap: 0 0 0

How could I get a "low memory alert" from Debian?
 

Der Müde Joe

Top Contributor
>How could I get a "low memory alert" from Debian?

try "top"
when linux starts swapping you will know

EDIT:
looks like you do not have any swap?
Swap: 0 0 0

mine is like:
total used free shared buffers cached
Mem: 3088884 1786932 1301952 0 187864 622076
-/+ buffers/cache: 976992 2111892
Swap: 3927884 0 3927884
 
Zuletzt bearbeitet:
M

maki

Gast
How could I get a "low memory alert" from Debian?
You probably won't, all you'll get is an OOME "unable to create new native thread" ;)

Could you try to reduce the stack size (-Xss256k, AFAIK the default is 512k)?
 

Mic

Mitglied
>How could I get a "low memory alert" from Debian?

try "top"
when linux starts swapping you will know

EDIT:
looks like you do not have any swap?
Swap: 0 0 0

mine is like:
total used free shared buffers cached
Mem: 3088884 1786932 1301952 0 187864 622076
-/+ buffers/cache: 976992 2111892
Swap: 3927884 0 3927884


I think missing swap display is due to that it is just a virtual server.

Problem with top is that I can't have an eye on it until that OOME occurs every 3 days...
 

Mic

Mitglied
You probably won't, all you'll get is an OOME "unable to create new native thread" ;)

Could you try to reduce the stack size (-Xss256k, AFAIK the default is 512k)?

Maybe there is any debian log showing a thread limit reached?

I will try reducing the memory, but since the OOME occurs not really often it will take some time to see or not see the effects...
 
M

maki

Gast
Maybe JMeter could help reproducing the problem.

Personally i think it's the OS that's running out of Resources, not the JVM, but i could be wrong there.
 

Mic

Mitglied
Maybe JMeter could help reproducing the problem.

Personally i think it's the OS that's running out of Resources, not the JVM, but i could be wrong there.

I already did some load testing but could not reproduce it. It seems not to be related to load... but maybe really to that virtual server's Debian reaching any limits. I will investigate with my provider.

Thanks for giving me that idea! I could have been debugging the VM's memory for months...
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
A Interpreter-Fehler OutOfMemory Exception mit Base64 decode Allgemeine Java-Themen 3
C Eclipse OutOfMemory nach dem exportieren Allgemeine Java-Themen 4
J BufferedReader OutOfMemory umgehen? Allgemeine Java-Themen 10
K Input/Output ObjectInputStream.HandleTable OutOfMemory Allgemeine Java-Themen 8
N OutOfMemory Allgemeine Java-Themen 5
G OutOfMemory Error bei Zahlenkonvertierungsprogramm Allgemeine Java-Themen 5
B Java OutOfMemory Error verhindern, Resourcenbedarf präventiv abschätzen? Allgemeine Java-Themen 19
N OutOfMemory nur wenn -Xmx gesetzt ist?! Allgemeine Java-Themen 6
E java.lang.outofmemory über windows-cmd ändern Allgemeine Java-Themen 6
R Speicherprobleme (OutOfMemory Error) Allgemeine Java-Themen 26
V JVM OutofMemory Linux geht, windows nicht Allgemeine Java-Themen 3
H java heap space (outofmemory error) Allgemeine Java-Themen 3
J ObjectInputStream und OutOfMemory Allgemeine Java-Themen 10
K OutOfMemory beim Entzippen Allgemeine Java-Themen 6
H Object cast exception Allgemeine Java-Themen 7
W Queue.remove() -> no such element exception Allgemeine Java-Themen 17
urmelausdemeis Exception in thread "main" java.lang.Error: Unresolved compilation problem: Allgemeine Java-Themen 7
N Kann ich die Nullpointer Exception umgehen Allgemeine Java-Themen 12
N A java Exception has occured Allgemeine Java-Themen 8
G javafx "class path" exception Allgemeine Java-Themen 5
H Interface PluginSystem ClassNotFound exception für library Klassen Allgemeine Java-Themen 10
tom.j85 Exception bei Abfrage von Ländercodes in API? Allgemeine Java-Themen 13
S Exception Allgemeine Java-Themen 5
LimDul Streams und Exception Allgemeine Java-Themen 8
C FileLock - Exception wird immer geworfen Allgemeine Java-Themen 4
S Wertbeschränkung Exception oder Anpassung? Allgemeine Java-Themen 4
D Nullpointer Exception Problem Allgemeine Java-Themen 5
Kirby.exe Nullpointer Exception bei Queue Allgemeine Java-Themen 5
R Schlüsselworte "Throw new exception" gibt nicht den String als Fehlermeldung aus Allgemeine Java-Themen 2
P Swing Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: npoints > xpoints.length || npoints > ypoints.length Allgemeine Java-Themen 5
S RMI Exception Allgemeine Java-Themen 0
S MSSQL Exception & Connection String Allgemeine Java-Themen 19
S Interface, generischer Datentyp, Exception? Allgemeine Java-Themen 3
coolian warum bekomme ich ein string index out of bounds exception Allgemeine Java-Themen 17
B Aufruf der Methode ergibt eine Exception Allgemeine Java-Themen 13
S Exception in thread "main" java.lang.NullPointerException at FamilienApp.main(FamilienApp.java:15) Allgemeine Java-Themen 1
M Klassen Serializable Exception Allgemeine Java-Themen 1
E HILFE !! Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils Allgemeine Java-Themen 4
E Thread Exception Allgemeine Java-Themen 6
javaerd Binomialkoeffizient ausrechnen, Exception in thread "main" java.lang.StackOverflowError Allgemeine Java-Themen 6
M xlsx File auslesen Exception occured Allgemeine Java-Themen 13
X jvm exception abfangen und an externes Programm schicken Allgemeine Java-Themen 4
G Java/LibGDX File Loading Exception Allgemeine Java-Themen 2
B Exception in Application init method Allgemeine Java-Themen 5
H OOP Testen einer Exception mit JUnit Allgemeine Java-Themen 8
M javafx ComboBox- Nullpointer Exception Allgemeine Java-Themen 6
perlenfischer1984 Dialect class not found exception Allgemeine Java-Themen 15
Thallius Bekomme keine Exception mit Stacktrace mehr. Was habe ich getan? Allgemeine Java-Themen 13
perlenfischer1984 Functionsparameter prüfen und eine Exception werfen !? Allgemeine Java-Themen 11
E Probleme mit nextInt() und Exception Allgemeine Java-Themen 35
Z Exception wird nicht ausgelöst Allgemeine Java-Themen 2
0 Animiertes Gif anzeigen - NullPointer Exception Allgemeine Java-Themen 19
T Konstruktor löst exception aus Allgemeine Java-Themen 7
KilledByCheese Dezimal nach Hexadezimal rechner wirft seltsame exception Allgemeine Java-Themen 4
V Compiler-Fehler Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Index: 125, Size: 125 Allgemeine Java-Themen 11
D Codeausführung bevor Exception abgeschlossen ist Allgemeine Java-Themen 11
T FileNotFound Exception Allgemeine Java-Themen 9
L Exception/Error auf JDialog umleiten Allgemeine Java-Themen 2
C Arithmetic Exception, obwohl nichts 0 ist Allgemeine Java-Themen 5
M A Java Exception has occured. Allgemeine Java-Themen 1
J Exception in thread "main" java.lang.NoClassDefFoundError Allgemeine Java-Themen 4
M Exception in thread "AWT-EventQueue-0" Allgemeine Java-Themen 6
P Input/Output java.util.Scanner in einer Schleife und Exception-Behandlung: Einlesen einer Zahl Allgemeine Java-Themen 4
E A Java Exception Has Occured Allgemeine Java-Themen 4
T Exception handling Allgemeine Java-Themen 7
P lazy loading exception Allgemeine Java-Themen 0
S Java Applet Crash - Keine Exception Allgemeine Java-Themen 8
S Best Practice verschiedene Exceptions fangen und neue Exception erzeugen Allgemeine Java-Themen 11
K Exception in thread "AWT-EventQueue-1" Allgemeine Java-Themen 2
K Gepacktes Jar-File gibt beim Doppelklick eine Exception aus Allgemeine Java-Themen 4
P Eigene Exception Klasse Allgemeine Java-Themen 7
N Java Interne Exception Allgemeine Java-Themen 4
B JUnit4 Exception-Test Allgemeine Java-Themen 4
127.0.0.1 SQL Exception, kein Driver Allgemeine Java-Themen 9
S Erste Schritte Exception beendet Schleife nicht - Methode macht trotz throw weiter? Allgemeine Java-Themen 9
R ZIP FileSystem unter Windows wirft exception Allgemeine Java-Themen 7
H java.util.Timer und Funktion mit SQL Exception Allgemeine Java-Themen 5
Ollek Barcode mit Barcode4J erzeugen - Exception Allgemeine Java-Themen 4
Z Concurrent Modification Exception - HashMap (kein remove) Allgemeine Java-Themen 4
E Eigene Exception Klasse erstellen Allgemeine Java-Themen 3
L Variablen IO Exception weil File angeblich nicht exisitert Allgemeine Java-Themen 10
T Exception versus Rückgabeparamter Allgemeine Java-Themen 26
S Exception enableDepthTest Allgemeine Java-Themen 7
M JAXB Reimport zu Hibernate DB -> Exception Allgemeine Java-Themen 3
W Kleine Frage zu Null-Pinter-Exception Allgemeine Java-Themen 21
aze JUnit: Testen ob bestimmte Exception nicht auftritt Allgemeine Java-Themen 18
S Null Pointer Exception bei BufferedReader Allgemeine Java-Themen 4
N Runtime.exec() Exception Problem Allgemeine Java-Themen 3
P Default constructor cannot handle exception type Allgemeine Java-Themen 6
M Objekt prüfen auf null ->Invocation Target Exception??? Allgemeine Java-Themen 2
S Bildaufbau durch Servlet -> Exception Allgemeine Java-Themen 11
E Queue: Wie kann hier ein null-Pointer Exception auftreten?! Allgemeine Java-Themen 11
S Exception beim Schreiben des Dataset in XML Datei Allgemeine Java-Themen 8
M Webstart Exception trotz signierten JARs Allgemeine Java-Themen 3
E Interpreter-Fehler unbekannte Exception Allgemeine Java-Themen 12
B Komische Exception Allgemeine Java-Themen 4
U SwingWorker und Exception Allgemeine Java-Themen 3
B Nullpointer Exception in Array Allgemeine Java-Themen 15
G WebService Exception Allgemeine Java-Themen 3
M Best Practices Exception Handling für eigene library Allgemeine Java-Themen 8

Ähnliche Java Themen

Neue Themen


Oben