Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Java in General and the fly likes string.trim() causing outofmemoryerror? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "string.trim() causing outofmemoryerror?" Watch "string.trim() causing outofmemoryerror?" New topic

string.trim() causing outofmemoryerror?

Ankit Thakkar
Ranch Hand

Joined: Apr 29, 2005
Posts: 33

Dear All,

we are facing outofmemory in production environment with jboss. we allocated 2 GB. we are having some owkward issue.
when this error comes up specific functionality doesn't work. but still users are able to access different functionality.
we noticed that when we have nullpointer exception in string.trim() or patter.compile() at this time we are getting outofmemoryerror.

if one user get outofmemoryerror other can still try with different functionality.

is there any possibility that string.trim for null value cause this error???

please help
Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Well, there are too many unknowns to be sure, but it seems to me like the problem may come from your error reporting. The only way to be sure would be to profile the application and see what is consuming so much memory.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
is there any possibility that string.trim for null value cause this error?

Trying to execute trim() on a String reference that is actually null will of course cause a NullPointerException which would only consume memory to build the stack trace. Not a very large amount of memory involved, look elsewhere.


I agree. Here's the link:
subject: string.trim() causing outofmemoryerror?
It's not a secret anymore!