[gdal-dev] C# OGR and memoryproblems.

Hallgren, Johan johan.hallgren at logica.com
Mon Oct 13 04:32:45 EDT 2008


Hello again Tamas

First of all, we are working with a web service, so problems will arise in the asp-working process.

Let's see here. What are you meaning with "open-shared option" you're mention?

We tried to use Dispose() on datasource but the program crashed immediately. Then we used feature.Dispose() but that one didn't solve the problem, the program still crash at the second round (second call from outside).

We managed to solve the problem by turning the Web Service into an EXE. To start with the problem also appeared in the EXE but we changed three things in the code that seemed solve the problem in the exe.

The first thing we added was a call to Dispose() on a feature that was used in a while-loop.

The second thing we added was a call to the Drivers DeleteDataSource().

The third thing was to encapsulate the code in a using-statement.

The error went away in the EXE. But when we tried the code in the Web Service and it seems as we still got the same memory problem at the second round there.

Maybe we did something wrong when using OGR in a multithread environment, but it's a bit unclear here how we should do it.

/Johan
___________________________________


Johan Hallgren


Logica
Pelle Bergs backe 3
Box 1938, 791 19 Falun
Tel (och mobil): 023-547 46 (int: +46-2354746)
johan.hallgren at logica.com
http://www.logica.se

-----Original Message-----
From: Tamas Szekeres [mailto:szekerest at gmail.com]
Sent: den 10 oktober 2008 23:37
To: Hallgren, Johan
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] C# OGR and memoryproblems.

Johan,

Assuming you don't use the open-shared option the destructor of the object should destroy the underlying dataset. For the garbage collected environments (like .NET) it would be reasonable to put this mechanism into an earlier method like Dispose, however it would require some further investigation to implement such code properly, you could submit a ticket with this problem anyways.

You could also test this issue by forcing the collection by using the
GC.Collect() API.

Best regards,

Tamas



2008/10/10 Hallgren, Johan <johan.hallgren at logica.com>:
> Hello
>
> We are using ogr to create a shapefile. We user C# as the development
> environment. We now have a problem that the process that runs the code
> doesn't release references to the shapefile. It's opened and created
> but there is no close function I could find.
>
> At the ogr-home-page I found OGRDataSource::DestroyDataSource( poDS );
> , it meybe can help me but I can't find any similar thing at the C# api.
>
> Anyone knowing what causes that problem.
>
> br
> Johan
>
> Johan Hallgren
> Logica
> Pelle Bergs backe 3
> Box 1938, 791 19 Falun
> Tel (och mobil): 023-547 46 (int: +46-2354746)
> johan.hallgren at logica.com http://www.logica.se
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



More information about the gdal-dev mailing list