This project is read-only.

Memory Leaks?

Topics: Developer Forum, Project Management Forum, User Forum
Apr 27, 2007 at 12:15 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 the 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;
_Map.Layers.Add(lyrStates);

Any feedback woulf be appriciated!! Thanks in advance.
Jun 18, 2007 at 11:52 AM
I experience the same.
Jun 27, 2007 at 12:43 PM
Edited Jun 27, 2007 at 1:18 PM
do:
mapDataSource3.Close();
mapDataSource3.dispose();
This is releasing memory after some connections.
I need to test more though!