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

Message ListMessage List     Post MessagePost Message

  Append Data To Contour Layer
Posted by Amal V R on Apr-28-2011 22:00
Hi Peter

I am dealing with contour chart where I have 4000 y value and 2000 x values therefore
Z values will be 4000*2000.

X values represents a scan,0 to 2000 scans.During end of each scan graph is updated.
My concern is,when i have to create new chart object and assigning values to the contour layer every time.

Example :

During the second scan x[0-2] and y[0-4000] and z=[0-2*4000] has to be given to the contour layer
for scan 3,again i have to calculate the z values and have to apply to the layer along with x and y values.
like wise up to 2000 scans,each time I have to create new chart object and new layer.

I don't think it is good method? Is there any other method like appending value to data set ?because we have already given some values in the previous scan all we need is just append new values.

Major concern is each time when we set the data,it seen that the x,y,and z arrays are cloned internally and kept in the chart,and it will remain in the memory until it is collected by GC. Since the scanning is very rapid in our application and since GC is not collected every time there is memory leak.

Profiling the application showed that  lot of MemoryStream instances are there in the memory,along with double arrays that we supplied.

I think MemoryStreams and arrays are not disposed properly in netchart.dll.I don't know please confirm it.If you want we will send you the .Net Profiler snap shot as a proof


Regards
Amal V R

  Re: Append Data To Contour Layer
Posted by Peter Kwan on Apr-29-2011 00:57
Hi Amal V R,

From your description, it does not seem to be a "memory leak". It is normal that the Garbage Collector does not collect memory until you are almost run out of memory. (You would need to contact Microsoft on why the .NET system behaves this way.) As long as you do not actually run out of memory, you may consider this as the normal behaviour of the .NET framework.

If you want to control when the Garbage Collector run (instead of letting the .NET framework automatically does this), you can always call "System.GC.Collect();" at any time you want. For example, you can call it everytime after you have created a new chart to replace an old chart. Please refer to Microsoft documentation for details.

Also, I think it is not possible to explicitly "Dispose" of any array of MemoryStream in the .NET framework. (There is no Dispose method in the array object or MemoryStream object.) In the .NET framework, the memory has to be freed by the .NET Garbage Collector. You can call "System.GC.Collect();" to ask .NET to run the garbage collector as frequently as you like.

In my opinion, cloning an array takes negligible time comparing to plotting the points in the array. So it should not affect the CPU usage. For the memory, if you do not think the .NET automatic garbage collection fits you need, you can call the garbage collector at any time you like.

Hope this can help.

Regards
Peter Kwan