Re: Using fixed-size data buffer with GtkPlot
Fabio da Silva <[email protected]> Mon, 27 Feb 2006 17:07:24 -0700
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
Nickolai, I understand your concerns and yes, it is no fun to run out of RAM when you are doing dynamic allocation. In fact, the first time it happened to me was when I left testrealtime.c from GTKExtra running for one full day. You can still do a dynamically allocated scheme where you specify your maximum amount of memory to be allocated. One you reach that limit you dump the results in a file that you can access later (granted that hard disks are also a limited memory pool and you should limit the amount of files you want to create.) If you are running an application with real-time characteristics you may think about creating a thread to save the data and not overload the CPU with hard disk access overhead. Take care, Fabio On Mon, 2006-02-27 at 15:26 -0600, Nickolai Dobrynin wrote: > Fabio, > > Thanks for your response. > > On 2/27/06, Fabio da Silva <[email protected]> wrote: > Hi there, > > I agree with Al. allocating points dynamically is not that > painful or > computer intensive. > > The cost of allocating points dynamically is not what I'm worried > about at all. > My problem is far more basic and newbie-like. Assume you allocate > your > data point array dynamically and assume your program runs for days and > days uninterrupted. Would you be OK about your system running out of > memory because you keep allocating memory on and on and on, to store > all the data points you receive at runtime, even though you only need > to > plot each once and discard? Is there no way to keep the memory usage > bounded? > > > However if you absolutely don't want to change the > size of your array dynamically and are plotting points that > are > connected somehow, you will have to fill up the memory area > that is not > used with the x-y values of the latest measurement point. This > is to > avoid the annoyance of seeing the connecting line go to some > random > place in the screen after the last point is measured. Now, > realize that > this means you will have to access the memory to write your > points N*N > times for every cycle. N is the number of points you are > statically > allocating. Soon enough you will find out that this solution > will bog > your application down quite a bit. > > This sounds true, but, once again, this is not the level I am at right > now. > I am asking about something that, no doubt, was done by every single > programmer who wants to plot things in real time and is not OK about > the > operating system running out of memory because his data set grows > indefinitely in size. > > > > Best regards, > > Nickolai ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642