[geos-devel] Unclear objects lifetime and ownership issues in Monotone Chain components

Mateusz Loskot mateusz at loskot.net
Wed Sep 24 14:30:13 EDT 2008


strk wrote:
> On Wed, Sep 24, 2008 at 04:56:29PM +0200, Mateusz Loskot wrote:
>> strk wrote:
>> > Truth is (and you know): GEOS needs a GC !
>> > Can't keep being considered 1:1 mapping with JTS if doesn't have
>> one...
>>
>> Any particular GC technique you have in mind?
>>
>> IMHO, one of possible and clean solution for this kind of issues in GEOS
>> is to apply GC in form of shared_ptr - smart pointer that controls
>> lifetime of objects and frees developers from knowing *when* an object
>> is/should be deallocated.
>
> As long as you're sure no circular references exist, shared_ptr
> wuold be fine.

I should precise I mean shared_ptr + weak_ptr. These two together solve
circular references issue.

> But the point is if we GEOS needs to directly
> map JTS algorithms, they are based on a conservativ
> garbage collector.

I can't answer this. However, I suppose it would be better if GEOS
implements the same algorithms as JTS does but not follows JTS
implementation line-by-line.

> GCJ uses the bohem one, and is very nice.

Bohem can solve some/many problems, but it's not native C++ and
portable option, it's yet another dependencies (a big one), etc.
I don't think it would meet users' needs and expectations ;-)

Smart pointers would do solve this problem easier with
less complex solution. Although, I'm afraid it would require a lot of work.

> Ever tried to build JTS natively ?

I've never got interested in GCJ. I prefer "native" implementations :-)

Best regards,
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the geos-devel mailing list