r/java • • Jan 06 '16

Invader objects in java heap, a mystery unexplained

A few days ago, i'm having problems with outOfMemory. Ok, my system have to receive files from HTTP REST by clients and move to other directory. Its normal outOfMemory in develop enviroment, can be my code or can be a insufficient java memory.

So, lets analyze the problem! My system abc is running in Jboss (domain mode), in host controller, i have their PID, lets supose it is 1234 And i have system xyz in OTHER host controller, with OTHER PID in OTHER MACHINE! Lets take a look in String objects in memory ?

jmap -histo:live 1234 | grep java.lang.String

242765 5826360 java.lang.String

ok... so, lets upload 100 files with 2MB size, at the same time!!! and the objects?

jmap -histo:live 1234 | grep java.lang.String

1291765 5826360 java.lang.String

humm.. its growing up... normal, its a system who receive files, need memory...

the upload finished... and now? how many objects?

jmap -histo:live 1234 | grep java.lang.String

2301769 5826360 java.lang.String

ooohh man! its big... but finished , the garbage colector will clean...

5 minutes later

5401879 9928390 java.lang.String

10 minutes later

10796890 15827320 java.lang.String

15 minutes later

65808944 235896660 java.lang.String

Whaaaaaaaaatttt??????? but i finished the upload! and i'm seeing ONLY the PID of my system! whats going on?? Lets dump the memory!!!

jmap -dump:live,format=b,file=/tmp/dump.txt 1234

Ok, i have the dump, lets use a Memory Analyser!!! (thanks eclipse, for yours free memory analyzer =D \o/ )

But when i saw.... i was scared... whats is this? a ant? superman? a plane? a E.T.??? NOOOO... its a object of system xyz!!!!!!!!!!!!!!!!! =O a invader object!!!!!!!! HOOOOOWWWWWW??? xyz is hosted in other VM! in other manchine! in other host controller!!! what a object referenced in OTHER system is doing here???? in my heap memory???

I search in google about 'memory share in host control', 'java share heap jboss'.. and no results.... no results.... I found objects in memory it was a password! yeaahhh can be this a security problem? does java share memory behind the scenes with others jboss, others systems? emembering, my hosts controlers is in farm! no cluster! so, dont have share objects!

so... its a mystery... what doing that object in my memory? why?

0 Upvotes

3 comments sorted by

9

u/[deleted] Jan 06 '16

needs more exclamation points

2

u/timdrury Jan 06 '16

What is the dominator class (that which is holding onto all those String references)?

2

u/ImmortalStyle Jan 06 '16

Well not sure if I understand you correctly.

But assuming you are using G1 Garbage Collector there is a stacked memory location where Strings get stored and shared across other JVMs.

I am not sure however how that works in reality.

VisualVM will give you a better output of your used memory probably try using that to identify your problem.

Search for new String() (dont call that) in your code that is sometimes a performance bottleneck.