Hi all,
I have a huge memory leak problem in what is really very simple data
insert code.
In my app I'm trying to use a typed dataset to insert into a database.
It adds quite a few rows (say hundreds). Unfortunately it has a big ass
memory leak and I dont understand why.
The code below demonstrates the memory leak. It's like nothing is
cleaned up after PerformOperatio n is called.
According to .net memory profiler, after running the console app, there
are huge numbers of undisposed objects and meory usage is through the roof.
I've tried to attach a screenshot from .net memory profiler showing what
I mean
Any help would be very much appreciated
Thanks
Simon
class Program {
static void Main(string[] args) {
for (int i = 0; i < 1000; i++) {
PerformOperatio n();
}
}
private static void PerformOperatio n() {
GPSPositionTabl eAdapter da = new GPSPositionTabl eAdapter();
GPSPositionTabl e tblGPSPositions = new GPSPositionTabl e();
GPSPositionRow currentRow = null;
for (int i = 0; i < 50; i++) {
currentRow = tblGPSPositions .NewGPSPosition Row();
currentRow.Down loadID = 1;
currentRow.TTUR eference = 9999;
currentRow.Time stamp = DateTime.Now;
currentRow.Lati tude = 66.66666666666;
currentRow.Long itude = 66.66666666666;
tblGPSPositions .AddGPSPosition Row(currentRow) ;
}
da.Update(tblGP SPositions);
}
}
I have a huge memory leak problem in what is really very simple data
insert code.
In my app I'm trying to use a typed dataset to insert into a database.
It adds quite a few rows (say hundreds). Unfortunately it has a big ass
memory leak and I dont understand why.
The code below demonstrates the memory leak. It's like nothing is
cleaned up after PerformOperatio n is called.
According to .net memory profiler, after running the console app, there
are huge numbers of undisposed objects and meory usage is through the roof.
I've tried to attach a screenshot from .net memory profiler showing what
I mean
Any help would be very much appreciated
Thanks
Simon
class Program {
static void Main(string[] args) {
for (int i = 0; i < 1000; i++) {
PerformOperatio n();
}
}
private static void PerformOperatio n() {
GPSPositionTabl eAdapter da = new GPSPositionTabl eAdapter();
GPSPositionTabl e tblGPSPositions = new GPSPositionTabl e();
GPSPositionRow currentRow = null;
for (int i = 0; i < 50; i++) {
currentRow = tblGPSPositions .NewGPSPosition Row();
currentRow.Down loadID = 1;
currentRow.TTUR eference = 9999;
currentRow.Time stamp = DateTime.Now;
currentRow.Lati tude = 66.66666666666;
currentRow.Long itude = 66.66666666666;
tblGPSPositions .AddGPSPosition Row(currentRow) ;
}
da.Update(tblGP SPositions);
}
}
Comment