Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

Bottlenecks

Thread view: 
Dado - 15 Jan 2006 21:47 GMT
I got:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap
space

Application presents a printable chart (2DGraphics) which could be pretty
large. Until few months  I wrote it in a free JCreator, but I saw that my
application become more complicated so I installed NetBeans 4.1 and its
Profiler. I was thinking that I will see which frames, for example, I forgot
disposed so they still eat my memory. With the Profiler I saw lot of threads
but still can't figure out how to optimize my application.

As an amateur, to simplified the simplicity of java (vs C++), I learned that
I only must disposed JFrame-s and sometimes start garbage collector, to free
the memory.Could you show me the way to see the cause of Exception from
above.
Tony Morris - 15 Jan 2006 23:10 GMT
> I got:
> Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap
[quoted text clipped - 11 lines]
> the memory.Could you show me the way to see the cause of Exception from
> above.

You will observe this error when the VM fails to allocate memory. You should
note that this is not the same as "out of memory", since a failed memory
allocation is potentially recoverable. For example, suppose your VM has
256MB heap space free, and you perform some operation that results in a
memory allocation attempt of 320MB - this will cause a OutOfMemoryError, but
obviously, the VM has plenty of memory available - just not for that
allocation. Are you performing a huge memory allocation? e.g. creation of a
large array. You may get away with simply assigning more heap space to the
VM with the -Xmx option.

Are you leaking external resources? I have seen quite often where code will
fail to close some file, socket, database connection in a finally block,
resulting in an implicit unwinding of the call stack, and therefore, the
call to close which is typically in the try block never executes. An
obscurity of this scenario is where the developer has indeed closed in a
finally block, but has used a local assignment to null to attempt to
determine if the close is necessary - this is flawed, albeit common.

Are you maintaining unnecessary strong references that continually grow?

See if this helps:
Can Java applications leak memory?
http://jqa.tmorris.net/GetQAndA.action?qids=38&showAnswers=true

Signature

Tony Morris
http://tmorris.net/

Java Questions and Answers
http://jqa.tmorris.net/

Dado - 16 Jan 2006 07:54 GMT
"Tony Morris" <not@telling.you> je napisao u poruci interesnoj
grupi:43cad5e2@quokka.wn.com.au...

>> I got:
>> Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java
[quoted text clipped - 40 lines]
>
> Are you maintaining unnecessary strong references that continually grow?

I setup VM as a follows:

on my Athlon 2300+ with a 512MB.

My application use a HSQLDB database and I don't think so that is something
unclosed from that side.
I suppossed that it is a long arrays which are the points for a 2DGraphics
drawing. But know in a finalizing step, I can't println the size of every
suspicious variable, so I need a IDE help to see the bottlenecks.

p.s.
you didn't comment my
Dado - 16 Jan 2006 07:58 GMT
> p.s.
> you didn't comment my precidation
[quoted text clipped - 4 lines]
> free
> the memory.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.