[geos-devel] Smart Pointers solve all MM problems?

Norman Vine nhv at cape.com
Thu May 29 08:32:41 EDT 2003


Martin Davis writes:
> 
> I'm not clear on whether you're saying that SmartPointers should 
> include reference counting or not.  

Yes I am really talking about reference counting

> I believe there is a 
> well-known problem with reference counting not handling circular 
> chains of pointers. 

I am not familiar with this but I can 'imagine' where circular references 
'might' be a problem but there is usually a simple solution
 
> Also, am I right in thinking that smart pointers don't help you 
> if you have functions which alloc memory structures and return 
> them? (Which happens all over JTS - e.g. in indexes and edge 
> graph structures).

Long lived objects can be handled specially or just use the ref count 
bumping trick

AFAIK all the interesting GEOS calls return their results as a 
Geometry pointer which can be easily passed to the core GEOS
library so it will never be deleted by the GEOS core as then it's ref
count will never fall to zero inside the library

FWIW
Two other projects I am much more actively involved with
http://plib.sf.net  an http://www.openscenegraph.org
are both 'graph' based libraries which both successfully use
reference counting to 'simplify' memory management 

Ref counting certainly isn't the only way to manage memory
and all that really matters is that GEOS doesn't leak but ref 
counting is a fairly simple method that has been proven to 
help however I do realize that it takes a 'leap of faith' to trust it:-)

Cheers

Norman




More information about the geos-devel mailing list