ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Memory leak
Posted by pramilav on Jun-24-2010 19:13
In my application we have used the "Real Time Chart" for my application. The memory in the taskmanager refreshes every minute and slowly it increases.

Is there any way to free those memory.

Help needed.

Thanks & Regards,
Pramilav

  Re: Memory leak
Posted by Peter Kwan on Jun-25-2010 00:52
Hi pramilav,

We would need to know who allocates those memory before we can know how to free them. Many things can allocate memory, and it also depends on your development framework (are you using .NET?), the database (are you using database?), and also whether you are writing a web or desktop application.

For .NET, a feature of .NET framework is that it will intentionly use up a lot of your memory. If the .NET system founds out it uses too much memory, it will do an automatic garbage collection. If this is the cause of the problem, that means the memory will never be used up. Up to a certain point, garbage collection will free to memory. You may refer to the Microsoft documentation for details (see http://msdn.microsoft.com/en-us/library/0xy59wtx.aspx). The Microsoft documentation also mentions how to force a garbage collection to immediately free memory.

Other parts of the code can also consume memory. For example, database, the networking system, or the file system can use memory as cache or buffer. For example, if you have more and more data, or are using more and more SQL queries, your database may buffer more and more data or caches more and more queries. When it uses a sufficiently large amount of memory, the database should automatically clear the cache. Again, that means the memory will not be used up.

To test for sure if there is a memory leak, you may update the realtime chart very fast, and wait for a long time to see if the memory usage increases without bound and finally used up all the memory. If the memory not increasing without bound, there is probably no leak, and it is just normal the .NET system operates this way.

If you still think there is a real memory leak, to troubleshoot the problem, you may need to separate your code into multiple parts, to see which part is responsible for the leak (eg. split into database part and charting part). To test the charting part, you may create a realtime chart using random numbers as data (similar to the realtime chart sample code). If you can create a realtime chart using random numbers and it leaks memory, is it possible to provide me with the sample code you are using?

Note that if you are writing a web application, it is also very common for the browser to  leak memory. (ChartDirector runs only on the server side, so any browser memory leak is not related to ChartDirector or to ASP.NET.)

Hope this can help.

Regards
Peter Kwan