Results 1 to 20 of 38
Thread: Issue with Java Heap Space
- 10-03-2009, 09:40 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
Issue with Java Heap Space
Hi Experts,
We have developped our Scheduer framework which basically schesdules the java classess at specified frequency. This Scheduler framework is nothing but similar to BEA Java Method server.
The problem i am facing is JAVA HEAP SPACE issue. After one or two days after scheduler is started , While invokation of Jobs(ie schedule java programs) starts throwing JVM out of heap space ERROR ...Infact I am relaesing all the resources then and there.
Also i specifed min 512MB and Max 1GB runtime parameters for JVM while i launch java.exe .java -Xms512m -Xmx1024m.
So i am not able to understand why i am getting heap space issue....! IS Garbage Collector not running ??
Also one more question , suppose in s system if there are many java based apps running like BEA webogic , ORACLE DB , and xyz java based application , whether all the three wil be sharing same JVM or each will have its own instance of JVM ??
EXPERTS PLEASE DO HELP ME..I DESPERATELY NEED HELP FROM PEOPLE WHO HAVE INDEPTH KNOWEDGE ABOUT JVM AND ITS INTERNAL WORKING.
- 10-03-2009, 09:54 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Seemingly not. Or at least, not correctly/completely.
Of course, just not enough is available to be garbage collected.
If they are each started separately (i.e. each with their own java command), of course they are all in their own JVM. The "java command" is the JVM.
Seeing the code for this "scheduler" (if you really believe that the problem is there), and any code that uses it, may help.
- 10-03-2009, 10:16 AM #3
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
hi thanks for the reply.
So you think that this is the issue with resource not getting freed ?
ok let me explain the logic to you , in scheduler framework there is a controller java class based on some scheduling algorithm , it schedules and invokes the jobs(ie java programs) hosted in the framework.
So at any point of time , it will be executing only one job and no concurency .
For invoking a job , i create a child thread and start invocation of the job , and wait for teh job to complete before i execute the next job. So if you see , the controller is a light weight program i mean relativey less data processinbg involved but i agree jobs that are running in the framework are heavy weight , So bascially what i am trying to get at is , since i a create a new child thread each time for each job invocation , the heap space occupied by jobs will automatically get released after the thread dies?
So where is the memory management problem existing ?
Also as you see , i am giving 1GB to JVM....thats quite a big thing....
Despite of this fact how are we still ending in HEAP SPACE ISSUE.?
Regards
Charan
- 10-03-2009, 10:39 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Not if you still have a reference to something, somewhere. I haven't seen your code, nor the programs involved. Also, if the "program" executed through the thread doesn't close some resource it is completely possible that the thread hangs around. But, something is still being held onto somewhere, I can't tell you where, as I haven't seen your code.
- 10-03-2009, 10:40 AM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
In any case, run the thing with a profiler.
- 10-03-2009, 10:42 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Also, judging by your other thread where you are attemtping to use "stop", I have no confidence in your abilities to do this correctly.
- 10-03-2009, 12:02 PM #7
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
heyy,
i guess you are judging my coding capabilities wrongly by looking in to the thread which i posted for stop() method.I must say in the other thread the answer u gave was wrong...please understand why java team makes a method deprecated. Functionality wise the stop() will defintely stop a thread no matter as per the documentation even though its deprecated..Dont think that deprecated method never work properly..u are absolutely wrong ....The notion is they work but its not advisabe to use them. thats it..as simple as that..........
Coming to this topic...let me put question straight.....suppose there is a thread which invokes a job or program which uses lot of resources and dint free them.....! After the job when compltes ,,,the thread will terminate ...and subsequenty the resources allocated for the thread also becomes eligible for garbage collection since scope of those resources is over and hence gc will collect ir...am i right?
- 10-03-2009, 01:15 PM #8
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
I didn't say it wouldn't "work". I said it is extremely "dangerous". I know why it is deprecated, and those reasons are more than good enough not to use it, ever, regardless of how much you may think you have it "under control". You seemingly don't.
- 10-03-2009, 01:19 PM #9
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
And, if you think the dprecation in this case is only "not advisable", you are dead wrong. You do know that memory leaks are one of the possible (and usually almost guaranteed) problems with that "stop", don't you?
- 10-03-2009, 01:20 PM #10
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
friend, in my code i dont have any mutex conditions or multipe thread synchronization sort of stuffs......only if those was existing ,,,then it would have been dangerous to use stop().
Since in my case none of the above are present..no harm in using stop()....the notion here is ...rather than leaving the job in a struck state ,,,i just wan tto kill it....! Any concerns?
- 10-03-2009, 01:31 PM #11
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Do what you wish. You seemingly know more than me.
- 10-03-2009, 01:31 PM #12
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
ok if memory leaks are guaranteed with stop(),,then i am ready to drop off using stop method...but tell me what other aternative i have instead of stop().
Understand this usecase.....say if the child thread invokes a job and timout for the job is set to 5mins....the funtionality of this job is to read some data from a third party site,.,,,but unfortunately its taking more than timeout interval ..and i want it to be stopped rather than alowing it to tak some more time..
then the only option i was left with is stop() isnt it??? or there are anyother way?
For this situation..i am damn sure interrupt() or flag based mechainsm to exit run is not possible...
i hope u understood the usecase i am talking about.
- 10-03-2009, 01:32 PM #13
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Not that I see any need for this "scheduler". That is what Timer and TimerTask are for.
- 10-03-2009, 01:33 PM #14
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 10-03-2009, 01:33 PM #15
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
ok if memory leaks are guaranteed with stop(),,then i am ready to drop off using stop method...but tell me what other aternative i have instead of stop().
Understand this usecase.....say if the child thread invokes a job and timout for the job is set to 5mins....the funtionality of this job is to read some data from a third party site,.,,,but unfortunately its taking more than timeout interval ..and i want it to be stopped rather than alowing it to tak some more time..
then the only option i was left with is stop() isnt it??? or there are anyother way?
For this situation..i am damn sure interrupt() or flag based mechainsm to exit run is not possible...
i hope u understood the usecase i am talking about.
- 10-03-2009, 01:36 PM #16
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
that was just a example i gave u...the operation i invokefrom the thread is out of my control ,..,.. ..if i kill the thread which invoked the operation also be killed?
- 10-03-2009, 01:40 PM #17
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
forget about scheduler..there are many reasons why we dint use timer and timer task..for our business logic..there werent appropriate ones..
hence we have our own scheduler...
- 10-03-2009, 01:41 PM #18
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Connections, and other IO type operations, may hang, thereby possibly preserving the entire thread, or, at the very least, the resources associated with those operations.
That is one of the problems with "stop", "suspend", and "destroy", that "cleanup" was done well, if at all, and that has only gotten worse in the versions since they were deprecated as there is no interest in bettering them since everyone is told not to use them anyway.
This is one case where I believe they should have not payed any attention to "backward compatability" and should have simply removed the methods, but "backward compatability" is very nearly a "holy grail". It is very important, but should have been sacrificed in this case.
- 10-03-2009, 01:43 PM #19
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
- 10-03-2009, 01:49 PM #20
Member
- Join Date
- Oct 2009
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Problem with Java Heap Space using Socket
By mvillara in forum NetworkingReplies: 3Last Post: 08-21-2009, 04:45 AM -
Java heap space OutofMemoryError
By everlast88az in forum Advanced JavaReplies: 3Last Post: 05-18-2009, 08:12 AM -
Java Heap Space
By sandeeprao.techno in forum Advanced JavaReplies: 19Last Post: 10-30-2008, 11:27 AM -
Java heap space error
By gezzel in forum New To JavaReplies: 19Last Post: 09-25-2008, 12:07 AM -
Java heap space?
By javanewbie in forum New To JavaReplies: 1Last Post: 06-24-2008, 06:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks