Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » About OutofmemoryException
About OutofmemoryException [message #466714] Mon, 16 January 2006 03:47 Go to next message
Eclipse UserFriend
Originally posted by: shikai.cn.ibm.com

In RCP application,if an OutofMemoryException is raised up,how can I do with
it??I used System.gc(),however it seems do not work.
Re: About OutofmemoryException [message #466717 is a reply to message #466714] Mon, 16 January 2006 13:43 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
Chances are if you're creating SWT widgets, you're not disposing them when you're finished, and it's the memory taken up by the OS that's the leak, rather than your application directly.

The wizards at Eclipse don't think it's a good idea to have finalize() call dispose(), so you've got to do it yourself.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=123765

Alex.
Re: About OutofmemoryException [message #466743 is a reply to message #466717] Tue, 17 January 2006 02:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: shikai.cn.ibm.com

Thank you for your explaination.
And now I checked my RCP app.In this app,all the UI is dynamic
generated.Such as Label,Button,Table.However I think I need not to dispose
then manually.I just use a resource factory to manage my other
resources,such as Color,Cursor,GC,Images.Is it right?And I use sleak tools
to trace my app.I found that only GCs and Cursor is leak.However the memory
is increased with 12M each time.And the Cursors seem to be the same ID.
How can I know where the memory is wasted?
Re: About OutofmemoryException [message #466749 is a reply to message #466743] Tue, 17 January 2006 12:08 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
You need to dispose() the widgets when you've finished with them. However, if all of them are being put into a Shell, then you just need to dispose the Shell and it should dispose everything that it contains.

If you're using a resource obtained by another factory (e.g. a flyweight pool) then yes, those will be reclaimed.

There's some debugging tools that you can enable to show how much memory is being used; search help.eclipse.org for 'memory' or this newsgroup (you can search via http://www.eclipsezone.com if you're reading it on a newsreader).

Lastly, it's possible to have Java memory leaks too. I remember a time I was appending transient items to a List and never emptying it ... suprisingly, it kept running out of memory too ;-)

Alex.
Re: About OutofmemoryException [message #466803 is a reply to message #466717] Tue, 17 January 2006 19:36 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
You are leaking Java objects. OutOfMemoryException comes from the JVM, not
the operating system. Leaking operating system resources will not cause
this to happen.

"Alex Blewitt" <alex_blewitt@yahoo.com> wrote in message
news:30369081.1137419059901.JavaMail.root@cp1.javalobby.org...
> Chances are if you're creating SWT widgets, you're not disposing them when
you're finished, and it's the memory taken up by the OS that's the leak,
rather than your application directly.
>
> The wizards at Eclipse don't think it's a good idea to have finalize()
call dispose(), so you've got to do it yourself.
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=123765
>
> Alex.
Re: About OutofmemoryException [message #466818 is a reply to message #466803] Tue, 17 January 2006 21:56 Go to previous messageGo to next message
Alex Blewitt is currently offline Alex BlewittFriend
Messages: 946
Registered: July 2009
Senior Member
That isn't necessarily true, although it may well be in this case. Passing objects across the JNI barrier can leak references to Java objects which can't then be garbage collected. For example, one might have a Table UI that is connected to a Table Model. Create enough of those and you may end up with a number of dangling references from JNI into the Java VM, which subsequently causes the Java VM to throw this exception.

Note: I'm not saying that the Table in SWT suffers from it; I'm just using it as an example of what might occur.

Alex.
Re: About OutofmemoryException [message #466873 is a reply to message #466818] Wed, 18 January 2006 19:56 Go to previous message
Steve Northover is currently offline Steve NorthoverFriend
Messages: 1636
Registered: July 2009
Senior Member
Nope, that's not true. OutOfMemoryException happens when you try to create
a Java object. I suppose it could happen that so many operating system
objects have been leaked that when Java needs to grow object memory, the
operating system malloc() call fails but I've never seen this happen.

Hey Alex, my intent is not to argue or split hairs with you. I just want to
make sure that people reading this look for Java object leaks rather than
operating system resource leaks when they get this error. That's all.

"Alex Blewitt" <alex_blewitt@yahoo.com> wrote in message
news:28889593.1137535006291.JavaMail.root@cp1.javalobby.org...
> That isn't necessarily true, although it may well be in this case. Passing
objects across the JNI barrier can leak references to Java objects which
can't then be garbage collected. For example, one might have a Table UI that
is connected to a Table Model. Create enough of those and you may end up
with a number of dangling references from JNI into the Java VM, which
subsequently causes the Java VM to throw this exception.
>
> Note: I'm not saying that the Table in SWT suffers from it; I'm just using
it as an example of what might occur.
>
> Alex.
Previous Topic:How do a add cell editors to my property descriptors
Next Topic:Changing the font size for my entire application
Goto Forum:
  


Current Time: Tue May 21 18:54:32 GMT 2019

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

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

Back to the top