Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Why these cursor can not be disposed??
Why these cursor can not be disposed?? [message #466713] Mon, 16 January 2006 03:45 Go to next message
Eclipse User
Originally posted by: shikai.cn.ibm.com

Hi,folks:

I used sleak tools to trace my resource creating and disposing.And I used
a resource pool to manage all of my images,cursors,GCs,etc.When a resource
is created,I put it into hashmap,and at last,I disposed all the objs in the
pool.

Here I got a problem,is about Cursor:


Cursor cur=new Cursor (display, SWT.CURSOR_HAND);
ResourceFactory.getInstance().put(cur);

After I disposed all the cursors in my pool,in sleak list,I found there
are so manay Cursors leaked there,and their handle are the same.



Here is my cursor disposing function:

private void disposeAllCursor(){
int count=curMap.size();
for (Iterator iter = curMap.values().iterator(); iter.hasNext();){
Cursor cur=(Cursor)iter.next();
//if(!cur.isDisposed()){
cur.dispose();
cur=null;
//}
}
curMap.clear();
System.out.println("dispose all cursors:"+count);
}
Re: Why these cursor can not be disposed?? [message #466720 is a reply to message #466713] Mon, 16 January 2006 15:33 Go to previous messageGo to next message
Eclipse User
Originally posted by: richkulp.us.NO_SPAM.ibm.com

What are you using as the key to your hashmap, is it the SWT.CURSOR_*
id? If it is, then you can have more than one cursor that uses the same
handle id. The handle id is simply a number that tells the cursor what
pointer image to use. So you must be careful that you only have one
cursor of a handle id set in your factory and to reuse that cursor.

shikai wrote:
> Hi,folks:
>
> I used sleak tools to trace my resource creating and disposing.And I used
> a resource pool to manage all of my images,cursors,GCs,etc.When a resource
> is created,I put it into hashmap,and at last,I disposed all the objs in the
> pool.
>
> Here I got a problem,is about Cursor:
>
>
> Cursor cur=new Cursor (display, SWT.CURSOR_HAND);
> ResourceFactory.getInstance().put(cur);
>
> After I disposed all the cursors in my pool,in sleak list,I found there
> are so manay Cursors leaked there,and their handle are the same.
>
>
>
> Here is my cursor disposing function:
>
> private void disposeAllCursor(){
> int count=curMap.size();
> for (Iterator iter = curMap.values().iterator(); iter.hasNext();){
> Cursor cur=(Cursor)iter.next();
> //if(!cur.isDisposed()){
> cur.dispose();
> cur=null;
> //}
> }
> curMap.clear();
> System.out.println("dispose all cursors:"+count);
> }
>
>
>

--
Thanks,
Rich Kulp
Re: Why these cursor can not be disposed?? [message #466741 is a reply to message #466720] Tue, 17 January 2006 02:35 Go to previous messageGo to next message
Eclipse User
Originally posted by: shikai.cn.ibm.com

Yes,I did it.And now,my hashmap only have 2 cursors,but in sleak views,there
are more than 1k cursors there.
And the ID are the same,is it a problem?Because sleak thinks them as leak.
Re: Why these cursor can not be disposed?? [message #466760 is a reply to message #466741] Tue, 17 January 2006 15:03 Go to previous message
Eclipse User
Originally posted by: richkulp.us.NO_SPAM.ibm.com

It depends on who created them. Did you create them? They could of been
created by another class that you didn't write.

But just to reiterate, you did not create a new copy of the cursor if
the map already contained an cursor with the same handle id. Is that
correct? If that is correct then it wasn't you that created them.

shikai wrote:
> Yes,I did it.And now,my hashmap only have 2 cursors,but in sleak views,there
> are more than 1k cursors there.
> And the ID are the same,is it a problem?Because sleak thinks them as leak.
>
>
>

--
Thanks,
Rich Kulp
Previous Topic:Which ActiveX controls are used by the browser?
Next Topic:mac requires win32 dll?
Goto Forum:
  


Current Time: Sun Oct 26 00:38:32 GMT 2014

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

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