Lamalain
Posts: 8
Joined: Wed Jun 22, 2005 9:20 pm
Location: Canada
Contact: Website

Nmea Parser Shrinking Memory

Thu Jun 23, 2005 5:23 pm

This is a follow-up to the "Nmea Parser Memory Leak" topic.

I have made a number of tests to identify the cause of the loss of memory when using the NmeaParser object.

Here are some of the findings:
- Memory starts "shrinking" as soon as a GPS has a valid connection to the Nmea parser.
- Calling the "GC.collect" function at regular interval does seem to slow down memory loss, but does not eliminate it.
- I tried to "close and open" the connection to the parser at regular interval, using the code below, but without any apparent effect.

objParser.PortEnabled = False
objParser.Dispose()
objParser = Nothing
objParser = New GpsToolsNET.NmeaParser
objParser.NoEvents = True
objParser.ComPort = 1
objParser.BaudRate = 4800
objParser.PortEnabled = True
System.GC.Collect()

Any clues or suggested methods to reclaim the memory?

Handren
Posts: 51
Joined: Fri Feb 11, 2005 12:02 pm
Location: Sweden

RE: Nmea Parser Shrinking Memory

Thu Jun 23, 2005 9:58 pm

We have performed different tests to determine whether or not we hade memory leaks in GpsTools. We haven’t found any memory leaks.
GC.Collect() works for us, we run it after we have read a number of GpsFix. We notice that amount of used memory decreases.

Regards,
Handren Mokre
Franson support

Lamalain
Posts: 8
Joined: Wed Jun 22, 2005 9:20 pm
Location: Canada
Contact: Website

RE: Nmea Parser Shrinking Memory

Thu Jun 23, 2005 10:37 pm

Hello Handren,

I am not sure why there is constant loss of memory when the Nmea parser is connected to the GPS. It might be because of the way the program is constructed.

I was wondering about that, and perhaps you could give me your opinion on the program structure:
- The NmeaParser object declared as "shared" in a special class, so that it can be accessed by all the forms of the application
- The NmeaParser object is created and connect to the GPS within a "public" procedure within a "utility" class
- When a gpsFix is needed, a call is made from within a form. The call to get a gpsFix is done within a function activated by a timer control.

I tried different methods, including creating a new parser object within each of the form. This also results in a steady decrease in memory.

The only thing I did not try is to use events within forms. It seems that events won't fire in forms which are opened as dialog (ie using the "form.showdialog" method), is that normal?
Also should there be any difference in memory usage when using events?

So to summarize:
- Did you test memory usage within a "multi-form" environment?
- Is it normal for events not to fire when opening a form using the "showdialog" method
- Is there a difference in the way the parser handles memory when used with events (or not)?

Any answer here would be very helpful

n2kua56
Posts: 3
Joined: Mon Jan 09, 2006 10:20 pm
Location: USA

RE: Nmea Parser Shrinking Memory

Mon Jan 09, 2006 10:47 pm

We are also experiencing a memory leak. We can watch
the available memory decrease once the connection
to the nmea parser is established. Stopping the
parser stops the memory leak.

We are using C# on a PDA with you GPS Tools 2.0.

Please advise us as we really need this fixed as soon
as possible.

Thanks

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Nmea Parser Shrinking Memory

Tue Jan 10, 2006 1:04 am

Some memory will be consumed, but not all(?). If you wait for a while the memory situation will be stable(?)

Regards,
Johan

Franson Support

n2kua56
Posts: 3
Joined: Mon Jan 09, 2006 10:20 pm
Location: USA

RE: Nmea Parser Shrinking Memory

Wed Jan 11, 2006 12:11 am

It seems like the memory leak stops after a little while (after consuming several MB) if you leave the connection established. However, in our application, we need to disconnect and connect to the GPS numerous times. By the time that this is done, we have used almost all of the memory and the program either runs very, very slowly or hangs.

The reason that we have to frequently disconnect and connect to the GPS is that we need to capture an accurate GPS reading and we have found that the GPSTools code does not always update the latitude and longitude values if you walk slowly from one point to another, within a small radius (about 100ft). It seems like there is a velocity threshold that you have to cross in order to get it to change over small distances (e.g. 10ft). On this subject, if there is a better way to force the GPSTools to refresh the lat/long value at any given time, please let me know.

THanks

n2kua56
Posts: 3
Joined: Mon Jan 09, 2006 10:20 pm
Location: USA

RE: Nmea Parser Shrinking Memory

Fri Jan 13, 2006 7:53 pm

The memory leak that we are experiencing seems to be the same as that found in previous appends on this forum. We have used GC.Collect to try to correct the problem, but it has not completely fixed the leak. It has only reduced the problem. So we still reach the point where we are very low on memory and the performance of the application is greatly affected. We really need to have a fix to this problem. Please help.

Thank you.

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Nmea Parser Shrinking Memory

Fri Jan 13, 2006 7:56 pm

I will take a look at this to see where the problem is.

Regards,
Johan

Franson Support

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Nmea Parser Shrinking Memory

Fri Jan 13, 2006 9:40 pm

If I understand you correctly you say that NmeaParser causes a memory leak each time PortEnabled is set to true.

If that was true the SerialPort sample should experiance the same problems. It does not. I have tested to start and stop it several times and there is no memry decrease. And definitly no in the mega byte magnitude. I have also tried to detect any memory leaks using CodeSnatch from Entrek, but not found any.

Try to see if there are any other parts of your solution that might consume the memory. Try to isolate different parts see what part in your application is causing the memory problems.

Regards,
Johan

Franson Support

Lamalain
Posts: 8
Joined: Wed Jun 22, 2005 9:20 pm
Location: Canada
Contact: Website

RE: Nmea Parser Shrinking Memory

Sat Jan 14, 2006 8:49 pm

Johan,

From the discussion we had, I do not think that there is a "memory leak" as such. From my (user) end of things, it seems that when you start the parser, it slowly consumes memory, until it reaches a maximum.

I would be very interested to know what this "maximum" memory use is (it seems to be rather large).

Also, I do not know how the parser is designed, but it seems a bit strange that it should require so much memory to work. So my other question is: would it be possible for you to modify the parser mechanism so that it only uses a limited amount of memory?

Regards

User avatar
johan
GpsGate
Posts: 15342
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Nmea Parser Shrinking Memory

Sun Jan 15, 2006 3:09 pm

The problem is that I cannot repeat this "slow increase in memory usage". And NmeaParser does not require much memory.

I would recommend that you take a look at the other parts of your solution to see if you can see anything there that consumes memory the way you describe.

Try to isolate each part in your system and test them separately.



Regards,
Johan

Franson Support

Return to “GpsTools”