Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsWhy these cursor can not be disposed??
https://www.eclipse.org/forums/index.php/mv/msg/148353/466713/#msg_466713
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.
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);
}]]>2006-01-16T03:45:59-00:00Re: Why these cursor can not be disposed??
https://www.eclipse.org/forums/index.php/mv/msg/148353/466720/#msg_466720
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]]>2006-01-16T15:33:58-00:00Re: Why these cursor can not be disposed??
https://www.eclipse.org/forums/index.php/mv/msg/148353/466741/#msg_466741
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.]]>2006-01-17T02:35:14-00:00Re: Why these cursor can not be disposed??
https://www.eclipse.org/forums/index.php/mv/msg/148353/466760/#msg_466760
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.
>
>
>