Is it possible to delete graphic object from the GraphicsOverlay? (remove from the heap!)

Discussion created by FerrariRace on Jan 15, 2018
Latest reply on Jan 15, 2018 by LSmallwood-esristaff

Hi everyone!

ArcGIS ideology uses an overlay model for representing  maps and objects on them. 

If I want to create some object allocated on the heap, I write:

Graphic* obj = new Graphic(this); (and something inside)

Next step, I put this object to overlay:


If I have a pointer to the object, I can manually delete it, if I want!

for example: delete obj;
I did it and all my application has crashed!


How can I delete an interesting item from overlay and also from the heap,  I want to avoid memory leackege !