Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Memory Leak
Memory Leak [message #444233] Sat, 09 October 2004 09:54 Go to next message
Ryan is currently offline RyanFriend
Messages: 34
Registered: July 2009
Member
Hi!

In my application, after I do a bunch of operations, I get a Java
OutOfMemoryError. Is it likely that this error is happening because I am
not disposing my SWT objects (i.e. widgets, images, etc.)?

I thought that SWT objects predominantly use native memory. If this is
true, then failing to dispose SWT objects would probably not be the cause
of an OutOfMemoryError. Is this correct?

Thanks!

Ryan
Re: Memory Leak [message #444278 is a reply to message #444233] Mon, 11 October 2004 09:36 Go to previous messageGo to next message
Thomas is currently offline ThomasFriend
Messages: 151
Registered: July 2009
Senior Member
See http://www.eclipse.org/articles/swt-design-2/swt-design-2.ht ml
for explanations on disposing resources.

You should dispose every :
- GC,
- Font,
- Image,
- Color
- Widgets
- Cursors
- or other SWT objet

that YOU have created (do not dispose OS ressources :) ).

Maybe you can try sleak
http://www.eclipse.org/articles/swt-design-2/sleak.htm to watch for memory
leaks.

"Ryan" <a@b.com> a
Re: Memory Leak [message #444369 is a reply to message #444233] Tue, 12 October 2004 13:20 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You are more likely to get a SWTError of type SWT.ERROR_NO_HANDLES if you
are leaking images, fonts, colours, widgets etc.

"Ryan" <a@b.com> wrote in message news:ck8cgq$qck$1@eclipse.org...
> Hi!
>
> In my application, after I do a bunch of operations, I get a Java
> OutOfMemoryError. Is it likely that this error is happening because I am
> not disposing my SWT objects (i.e. widgets, images, etc.)?
>
> I thought that SWT objects predominantly use native memory. If this is
> true, then failing to dispose SWT objects would probably not be the cause
> of an OutOfMemoryError. Is this correct?
>
> Thanks!
>
> Ryan
>
Re: Memory Leak [message #444426 is a reply to message #444233] Tue, 12 October 2004 15:43 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
OutOfMemoryError is never causes by leaking operating system resources.
Rather, it is caused by "leaking" Java objects. How is this possible when
Java is a garbage collected language? A Java object is "leaked" when an
application unintentionally keeps a reference to an object (say in a static
variable) and the garbage collector can't do its job. When an SWT object is
disposed, not only are operating system resources released but interal
object references are set to null so that, even if an application were to
hold into an SWT object and defeat the garbage collector, the objects inside
can be released. It's the best we can do.

"Ryan" <a@b.com> wrote in message news:ck8cgq$qck$1@eclipse.org...
> Hi!
>
> In my application, after I do a bunch of operations, I get a Java
> OutOfMemoryError. Is it likely that this error is happening because I am
> not disposing my SWT objects (i.e. widgets, images, etc.)?
>
> I thought that SWT objects predominantly use native memory. If this is
> true, then failing to dispose SWT objects would probably not be the cause
> of an OutOfMemoryError. Is this correct?
>
> Thanks!
>
> Ryan
>
Re: Memory Leak [message #444434 is a reply to message #444233] Tue, 12 October 2004 16:32 Go to previous message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Hi Ryan,

You can use JProbe Memory Debugger or Optimizeit tools to find out what's
wrong in your app. Might be as simple as an innocent looking Hashtable that
stores one billion of String by accident...

Chris
Previous Topic:Label Wrap
Next Topic:SWT/AWT Incompatibility on Mac OS X
Goto Forum:
  


Current Time: Thu Apr 25 00:52:23 GMT 2024

Powered by FUDForum. Page generated in 0.03524 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top