LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Out of memory with PlotXY in CVI2013

Hello,

 

I want to plot an XY graph with 3 lines and a number of point of 100000 per line acquiring from a measurement device.

Every thing works fine until the number of measured points is reaching about 65536(?). Then the amount of memory is increasing rapidly up to 4 GB and the error message appears:

 

NON-FATAL RUN-TIME ERROR:   "grafik.c", line 121, col 13, thread id 0x000012E8:   Library function error (return value == -12 [0xfffffff4]). Out of memory

 

Before that the memory is only increasing about some hundred of kB for each plotting, as expected.

 

Maximum number of points is defined as INT_MAX = 2^31, so there should be no problem.

 

I am using

DeleteGraphPlot (pnlhandle, PNL_GRAPH, -1, VAL_NO_DRAW);

and

RefreshGraph (pnlhandle, PNL_GRAPH);

after the function PlotXY.

 

Any idea or workaround?

 

Best regards

 

Gunther

0 Kudos
Message 1 of 10
(5,134 Views)

Hi Gunther,

 

plotting three lines each with 100000 points using PlotXY works well in CVI2013f1. All I needed to do is increase stack size to allow for the large arrays. Can you provide a sample project?

0 Kudos
Message 2 of 10
(5,131 Views)

Hi Wolfgang,

 

do you mean the "Maximum stack size (bytes)" in the "Build options" menu?

I have changed the value from 1048576 (default) to 2048576 but with no effect to my problem (debug and release mode).

 

I am afraid that I could not send you a project with this problem. Extracting the code from my original project will take too long.

 

Maybe some more inforamtion helps to describe the problem:

 

I am logging data from an external device (3 channels with around 500 data/s per channel) and plot those data every 10 measurments to reduce the CPU load because of the PlotXY function which is not very fast. This is done in an timer interval routine.

 

Logging and printing is fine up to 65540(?) values per line. Memory usage for the program up till then is about 14 MB (task manager). Then the memory is increasing about 40 MB per new plot unitl it reachers nearly 4 GB (before, the increasing of memory was about 40 kB per new plot).

 

 

Best regard

 

Gunther

0 Kudos
Message 3 of 10
(5,121 Views)

OK, so I am attaching the little demo I have used to check your issue... you can try it and see if it does not work for you...

 

Concerning your questions:

 

yes, I was referring to the stack size found in build options; for the sample provided the standard stack size is too small, so I have it increased to 2000000.

 

I have changed data and plot size and did not see the memory usage increase abnormally as desribed by you

 

In any case I would consider the possibility to reduce data size: no monitor can resolve that many data points and plotting gets very slow.

0 Kudos
Message 4 of 10
(5,117 Views)

Hi Wolfgang,

 

many thanks for your support.

 

Starting your project immediately fails with the error

 

FATAL RUN-TIME ERROR:   "t.c", line 31, col 16, thread id 0x000027DC:   The program has caused a 'Stack overflow.' fault at 0x00408877.

 

at this line: double y [ points ];

 

Reducing the "points" below 65000 will work!!!

 

 

Best regards

 

Gunther

0 Kudos
Message 5 of 10
(5,115 Views)

That's why I needed to increase stack size Smiley Wink After that it should work for your 100000 data points, too.

0 Kudos
Message 6 of 10
(5,105 Views)

Hi Wolfgang,

 

I have increassed stack size to 2000000000 !!!!! but without any change in result. Still stack overflow!!

 

Gunther

0 Kudos
Message 7 of 10
(5,103 Views)

Hi Wolfgang,

 

I have tested your project on another PC with CVI2012.

 

There was an error message

"29, 22   Integer expression must be constant"

at

double x [points]; and double y [points];

I change the x and y to fixed size double x[100000] and double y [100000] and after increasing stack size the program works!!

 

So there is something wrong with my CVI2013f1 system. But I don't know what.

 

Gunther

 

0 Kudos
Message 8 of 10
(5,096 Views)

Then I am at a loss...

 

Below are my build settings I have used successfully for the sample program

 

build.png

0 Kudos
Message 9 of 10
(5,095 Views)

Hello,

 

I found the problem.

 

If you enable "Copy original plot data" in the "Edit Graph" dialog then the memory error occurs.

Disabling this function is the solution.

This only happens in my application with a continious data logging and plotting of more than 65000 points per line.

 

I think that this is a bug!?

 

 

Best regards

 

Gunther

0 Kudos
Message 10 of 10
(5,015 Views)