[fdo-users] .net Wrapper quirks

Romica Dascalescu Romica.Dascalescu at autodesk.com
Sat Nov 1 14:50:05 EDT 2008


Hi Jackie,

Two more comments:
- Close the connection after use
- In case Execute() function from a FDO command returns a reader, even you are not interested in that reader, get it close it and release it (“using(reader){}”).
I know “using” is not looking nice in the code but makes coding with FDO objects safer.

Regards,
Romy.
________________________________________
From: fdo-users-bounces at lists.osgeo.org [fdo-users-bounces at lists.osgeo.org] On Behalf Of Romica Dascalescu
Sent: Saturday, November 01, 2008 2:35 PM
To: FDO Users Mail List
Subject: RE: [fdo-users] .net Wrapper quirks

Hi Jackie,

First I would avoid calling FDO_object.Dispose();
Now try using "using" with FDO objects you will be sure the object is released after is used.
I modified your file, try it and see if you still get the crash.

Regards
Romy.
________________________________________
From: fdo-users-bounces at lists.osgeo.org [fdo-users-bounces at lists.osgeo.org] On Behalf Of Jackie C. Ng [jumpinjackie at gmail.com]
Sent: Saturday, November 01, 2008 1:44 AM
To: fdo-users at lists.osgeo.org
Subject: RE: [fdo-users] .net Wrapper quirks

I'll cite a more concrete example:

http://code.google.com/p/fdotoolbox/source/browse/sandbox/FdoToolbox.Lib/Controls/GenericSpatialConnectCtl.cs#220

This code builds the grid cells to allow you to enter the connection
properties. Using the latest FDO trunk, if the provider is OGR, then once
the method has completed, the application will die (with
System.AccessViolation) if you switch (alt-tab) to another application and
back in.

With pdbs, the error message becomes:

Unhandled exception at 0x0522f116 in FdoToolbox.exe: 0xC0000005: Access
violation reading location 0xfeeefefa.

With the point of failure being at:
OSGeo::FDO::Connections::IConnectionPropertyDictionaryImp::ReleaseUnmanagedObject()

Now if I were to disable the using block on the connection that gets created
(ie. Don't Dispose() the connection), I no longer get this access violation!

Hence the Dispose() or no? question. I am confused.

- Jackie


Donald Cameron wrote:
>
> I find my code throws exceptions on termination if I don't dispose of any
> readers I have created during its execution.
>
> Don
>
> -----Original Message-----
> From: fdo-users-bounces at lists.osgeo.org
> [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Jackie C. Ng
> Sent: Friday, October 31, 2008 8:56 AM
> To: fdo-users at lists.osgeo.org
> Subject: RE: [fdo-users] .net Wrapper quirks
>
>
> Sorry to necro this discussion but it seems the dreaded
> System.AccessViolationException has reared its ugly head again in my
> testing
> of FDO Toolbox with the PostGIS and OGR providers (I'm testing on the
> trunk
> build of FDO). I guess I need clarification on the following matters:
>
> 1 - Dispose() or no? Should I just be letting the GC do its job. Could I
> be
> screwing up reference counts by Disposing objects myself, thus possibly
> causing these errors?
>
> 2 - The devguide states that method chaining is bad. Does this still apply
> with the managed wrappers?
>
> - Jackie
>
>
> gregboone wrote:
>>
>> This is the primary cause of the defect as it results in an excessive
>> number of SQLite resources being instantiated and used before enough
>> resources are freed by the garbage collector. As a work-around, calling
>> Close()/Dispose() should resolve the issue. However, we will also try and
>> make a fix in the SDF provider so that these steps are not explicitly
>> necessary.
>>
>> One last point, you still should explicitly assign the result of Execute
>> to a Feature Reader so that the garbage collection can happen at an
>> appropriate time.
>>
>> Greg
>>
>> -----Original Message-----
>> From: fdo-users-bounces at lists.osgeo.org
>> [mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Jackie Ng
>> Sent: Friday, April 04, 2008 2:38 AM
>> To: fdo-users at lists.osgeo.org
>> Subject: Re: [fdo-users] .net Wrapper quirks
>>
>>
>> I just looked at the unit test code for the ticket, and noticed I might
>> have
>> been doing something wrong.
>>
>> I forgot that IInsert::Execute() returns an IFeatureReader and so I
>> haven't
>> been closing and disposing them.
>>
>> One (of many?) possible cause(s)?
>>
>> - Jackie
>>
>>
>> Jackie Ng wrote:
>>>
>>> Hi All,
>>>
>>> I've been writing .net code that copies data from one FDO connection to
>>> another (Doing a series of IInsert::Execute() calls from an
>>> IFeatureReader
>>> ). In my adventures using the FDO .net wrapper, I have encountered the
>>> following problems at random:
>>>
>>> - System.AccessViolationExceptions ("Attempted to read or write
>>> protected
>>> memory. This is often an indication that other memory is corrupt")
>>> thrown
>>> at OSGeo.FDO.Runtime.Disposable.Finalize() (Target Site: void
>>> ReleaseUnmanagedObject() )
>>> - C++ pure virtual function call errors.
>>> - Memory allocation failed errors.
>>>
>>> Is there some quirks with the .net wrapper that I should be aware of? As
>>> OSGeo.FDO.Runtime.Disposable implements IDisposable, I've been wrapping
>>> nearly every FDO object used inside using() blocks. Could this be a
>>> cause?
>>>
>>> I am using .net wrappers for FDO 3.3.0
>>>
>>> - Jackie
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/.net-Wrapper-quirks-tp16318694s18162p16485877.html
>> Sent from the fdo-users mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> fdo-users mailing list
>> fdo-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>> _______________________________________________
>> fdo-users mailing list
>> fdo-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/fdo-users
>>
>>
>
>
> -----
> http://themapguyde.blogspot.com
>
> http://www.linkedin.com/in/jackieng
> --
> View this message in context:
> http://www.nabble.com/.net-Wrapper-quirks-tp16318694p20265376.html
> Sent from the FDO Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fdo-users mailing list
> fdo-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
> _______________________________________________
> fdo-users mailing list
> fdo-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fdo-users
>
>


-----
http://themapguyde.blogspot.com

http://www.linkedin.com/in/jackieng
--
View this message in context: http://www.nabble.com/.net-Wrapper-quirks-tp16318694p20277762.html
Sent from the FDO Users mailing list archive at Nabble.com.

_______________________________________________
fdo-users mailing list
fdo-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/fdo-users


More information about the fdo-users mailing list