Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Memory Leak
Memory Leak [message #444233] Sat, 09 October 2004 05:54 Go to next message
Eclipse UserFriend
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 05:36 Go to previous messageGo to next message
Eclipse UserFriend
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 09:20 Go to previous messageGo to next message
Eclipse UserFriend
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 11:43 Go to previous messageGo to next message
Eclipse UserFriend
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 12:32 Go to previous message
Eclipse UserFriend
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: Sun Jul 06 08:18:23 EDT 2025

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

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

Back to the top