ps4000astreaming example memory problem

Having problems ? let us know the details here
Post Reply
Ondrej
User
User
Posts: 3
Joined: Thu Dec 14, 2017 2:55 pm

ps4000astreaming example memory problem

Post by Ondrej » Thu Dec 14, 2017 3:18 pm

Hello,
I tried to use your c++ data streaming example from github for PicoScope 4444. It seems that there is some problem with taking and not releasing memory. I have tried to perform long-term data streaming but the program gradually fulfilled entire available memory. I think that it should not work like that since the API guidance claims that those buffers are FIFO types of memory. Even the allocation functions are called only once.
I am not able to find the reason why it consumes so much memory. Let's say that my settings are as follows:

Code: Select all

timeUnits = PS4000A_NS;
sampleInterval = 100; //10MSs;
postTrigger = 400000000; //aprox. 40s
all channels enabled, writing to file skipped (commented - for testing and better performance purposes)

Should it behave like that and if so, is there to way how to fix it or at least how to address those data stored in memory?

Thank you for help in advance.

Hitesh
Site Admin
Site Admin
Posts: 2845
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000astreaming example memory problem

Post by Hitesh » Mon Dec 18, 2017 11:16 am

Hi Ondrej,

The driver will store raw data values in memory in streaming mode so that data can still be requested post-capture.

What are you seeing in terms of memory usage of the application i.e. how many MB?

Regards,
Hitesh

Technical Support Engineer

Ondrej
User
User
Posts: 3
Joined: Thu Dec 14, 2017 2:55 pm

Re: ps4000astreaming example memory problem

Post by Ondrej » Mon Dec 18, 2017 1:59 pm

Hi Hitesh,
I have performed the experiment: 4 channels enabled, sampling interval 100 ns (10MS/s) for 100 seconds.
In the beginning, the application took about 4MB, and at the end of the measurement, it was about 6,5GB.

Is there a way how to read raw data collected by the driver? Since the data are already in memory, it would be way effective to perform the measurement first and save it to the file afterwards.

In this example, there is the continuous saving of data to the file during the measurement, which slows the application. My computer allows me to save to the binary file only two channels at the rate of 10MS/s in real time (SSD). Higher sampling rate or more than two channels will not be in real time. Without the saving to the file, I can run the application up to 100MS/s, but I don't know how to address the collected data in the driver's memory.

Ondrej

Hitesh
Site Admin
Site Admin
Posts: 2845
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: ps4000astreaming example memory problem

Post by Hitesh » Mon Dec 18, 2017 2:49 pm

Hi Ondrej,

You can use the ps4000aGetValuesAsync() function to retrieve the data from the driver post-capture so you don't have to write to file while collecting data as the example does.

The function above can use the same streaming callback as you would with the ps4000aGetStreamingLatestValues() - you just need to setup the buffers to be large enough to write the data into.

Hope this helps,
Hitesh

Technical Support Engineer

Ondrej
User
User
Posts: 3
Joined: Thu Dec 14, 2017 2:55 pm

Re: ps4000astreaming example memory problem

Post by Ondrej » Tue Dec 19, 2017 3:02 pm

Hi Hitesh,
thank you, this solution works :)

Post Reply