This project has moved and is read-only. For the latest updates, please go here.

Memory Leaks?

Topics: Data Access
Apr 27, 2007 at 12:12 AM
Edited Apr 27, 2007 at 12:14 AM
I have a little problem. I am using SharpMap and MsSqlSpatial with SqlServer 2005. I am noticing that the sqlservr.exe process (in Task Manager) is using more and more memory with every connection to SqlServer, and it is not ever being released. The sqlservr.exe process memory appears to bump up when I call the following line of code and it does not release it.

Bitmap theBitmap = (Bitmap)_Map.GetMap();

Why am I seeing this memory issue in the database as opposed to the client application? I am guessing that this is a memory leak in MsSqlSpatial because it appears in the sqlservr process and not in my client program. Does anyone know what is causing this? I am using SharpMap to create tiles for a "tile server" used by Google Maps, so I need to open and close connections constantly.

I am connecting to SqlServer/MsSqlSpatial like so...

Map _Map = new Map(new System.Drawing.Size(256, 256));

// Add States
SharpMap.Layers.VectorLayer lyrStates = new SharpMap.Layers.VectorLayer("tblGeoStates");
SharpMap.Data.Providers.MsSqlSpatial mapDataSource3 = new SharpMap.Data.Providers.MsSqlSpatial(sConnect, "tblGeoStates", "the_geom", "oid");
SharpMap.CoordinateSystems.ICoordinateSystem coordinateSystem3 = GeographicCoordinateSystem.WGS84;
lyrStates.CoordinateTransformation = Transform2Mercator(coordinateSystem3);
lyrStates.DataSource = mapDataSource3;
lyrStates.Style.Fill = new SolidBrush(Color.FromArgb(10, 0, 0, 255));
lyrStates.Style.EnableOutline = true;
Pen oP = new Pen(Color.FromArgb(150, Color.Maroon));
oP.Width = 1;
lyrStates.Style.Outline = oP;

Any feedback would be appreciated!! Thanks in advance.