Aha. Its not adding/removing shapes at all. The GDI heap memory leak is caused
by a simple repaint of the window.
This can be reproduced most easily by using the stress tool that comes with
MSVC6. (Or just repeatedly call Refresh())
If you run the OGL demo prog from the wxpython demos and the stress tool and hit
ctrl-insert to cause a refresh of the screen the GDI memory slowly leaks away.
This happens alot faster with my app as I've got 100's of bitmapshapes.
So, would this be a problem in OGL's bitmapshape repaint or elsewhere???
Raul Cota <cota@ucalgary.ca> writes:
Right now I use OGL to connect unit operations (shapes) and when ever I
load a new case, I delete all the shapes from it, and then add the new
ones, and I still haven't had those problems (maybe I haven't tested
enough though).I just ran my application and opened and closed cases a lot of times, to
see if I get that problem and I didn't (but I don't really know what
"many" menas for you).#This is how I delete shapes (code for deleting lines not included).
canvas = self.pfd
dc = wxClientDC(canvas)
canvas.PrepareDC(dc)
redraw = false
#imgsUO is a member dict with an instance of all the shapes
for i in canvas.imgsUO.keys():
shape = canvas.imgsUO[i]
canvas.RemoveShape(shape)
del canvas.imgsUO[i]
shape.Destroy()
canvas.Refresh()The only difference I see is that I don't use Erase (sorry, I haven't
done reference count yet)
You're right, Erase is superflous - left over from when I wanted to delete a
shape without causing a whole diagram refresh.
Yes, I dont get the problem if I delete all, which I do (similarly to your code)
for shape in self.theDiagram.GetShapeList():
if shape.GetId() != self.backgroundShapeID:
self.theDiagram.RemoveShape(shape)
shape.SetCanvas(None)
shape.Destroy()
# print 'bitmap refcount',sys.getrefcount(self.featureTemplates[0].wxbitmap)
self.featureTemplates =
but I do when deleting one, which perhaps suggests an internal issue when
removing one shape and calling refresh. Or perhaps <canvas>.RemoveShape()
actually does more than call <canvas>.<diagram>.RemoveShape(). Hmm, more testing
needed to find out what I'm doing wrong.
Given I have to refresh the whole diagram on a delete its probably only a
marginal cost to deleteAll and recreate them.
Thanks for the help.
···
Raul
I use Win NT, wxPython 3.2.1
python@lee-morgan.net wrote:
>
> Hi,
>
> I'm bending OGL's purpose a little and trying to use it as a very simple 2D mapping
> component (if anyone knows a better solution I'd love to hear it!).
>
> So, I've got many small bitmaps arranged on a background. When I delete them I
> eventually exhaust the GDI heap.
>
> my delete involves
>
> dc = wxClientDC(self)
> shape.Erase(dc)
> self.theDiagram.RemoveShape(shape)
> shape.SetCanvas(None)
> shape.Destroy()
> self.Refresh()
>
> shape has a getrefcount() of 4, which is odd. 1 for getrefcount, 1 in the delete
> function but the others I can't account for.
>
> My first thought was the shapes are being kept alive, but it appears that
> deleting exhausts the heap much quicker than adding alot of bitmap shapes.
>
> So perhaps its the refresh thats causing some sort of duplication??
>
> Has anyone got any ideas or experience with this?
>
> Cheers
>
> --
> wxPython
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users
--
wxPython