|
From: tryfonaration <far...@gm...> - 2013-10-30 16:20:38
|
Hello, I am using a simple C library from here http://ndevilla.free.fr/gnuplot/ to plot real-time data with gnuplot. It basically opens a pipe to gnuplot and you can feed it with data and commands. I want to plot an image that changes periodically. I make the following command string "plot '-' matrix with image", then concatenate a big chunk of data and then pipe it to gnuplot. This is done every a few seconds. What happens is that my program occupies more and more memory every time a new command is issued and eventually the OS kills it. Any idea why this could be happening? -- View this message in context: http://gnuplot.10905.n7.nabble.com/Memory-overload-in-real-time-plotting-tp17795.html Sent from the Gnuplot - User mailing list archive at Nabble.com. |
|
From: Ethan M. <eam...@gm...> - 2013-10-30 18:20:47
|
Please clarify. Is the memory growth happening in gnuplot or in the program at the other end of the pipe? If the latter, I don't see how we could make a guess at the problem without seeing your code. I just had a very quick look at the code in gnuplot_1-2.11 from the URL you mentioned. It looks like the library itself allocates new memory on every call to gnuplot_init() and frees it in gnuplot_close(). Are your calls to these routines correctly paired? On Wed, Oct 30, 2013 at 9:20 AM, tryfonaration <far...@gm...>wrote: > Hello, > > I am using a simple C library from here http://ndevilla.free.fr/gnuplot/to > plot real-time data with gnuplot. It basically opens a pipe to gnuplot and > you can feed it with data and commands. I want to plot an image that > changes > periodically. I make the following command string "plot '-' matrix with > image", then concatenate a big chunk of data and then pipe it to gnuplot. > This is done every a few seconds. What happens is that my program occupies > more and more memory every time a new command is issued and eventually the > OS kills it. > Any idea why this could be happening? > > |
|
From: tryfonaration <far...@gm...> - 2013-10-31 08:33:47
|
The memory growth is observed in the program not gnuplot. This is the code
that is being called periodically every few seconds. extents_plot_handler =
gnuplot_init(); is only called once at some previous point.
int i;
char * cmd_header = "plot \"-\" matrix with image\n";
char * cmd = malloc(
sizeof(char)
* ((4 * extents_map_size)
+ (int) (extents_map_size / pixels_width) + 30));
strcpy(cmd, "");
cmd = concat(cmd, cmd_header);
for (i = 1; i <= extents_map_size; i++) {
cmd = concat(cmd, addr_space_extents_array[i - 1]);
if (i % pixels_width == 0) {
cmd = concat(cmd, "\n");
}
}
if (extents_map_size % pixels_width > 0) {
for (i = extents_map_size;
i
< (extents_map_size + pixels_width
- (extents_map_size % pixels_width)); i++) {
cmd = concat(cmd, "0 ");
}
}
if (extents_map_size % pixels_width > 0)
cmd = concat(cmd, "\ne\ne");
else
cmd = concat(cmd, "e\ne");
/*FILE *file;
char file_name[20];
sprintf(file_name, "temp_data%d.txt", temp_counter++);
file = fopen(file_name, "a+");
fprintf(file, "%s", cmd);
fclose(file);*/
fprintf(stderr,"extents_plot_handler size:
%d\n",sizeof(extents_plot_handler));
fprintf(stderr,"extents_plot_handler file size:
%d\n",sizeof(extents_plot_handler->gnucmd));
fprintf(stderr,"extents_plot_handler active plots:
%d\n",extents_plot_handler->nplots);
fprintf(stderr,"extents_plot_handler temporary files:
%d\n",extents_plot_handler->ntmp);
fprintf(stderr,"extents_plot_handler temp filename table size:
%d\n",sizeof(extents_plot_handler->tmp_filename_tbl));
gnuplot_cmd(extents_plot_handler, cmd);
free(cmd);
--
View this message in context: http://gnuplot.10905.n7.nabble.com/Memory-overload-in-real-time-plotting-tp17795p17798.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: Ethan A M. <EAM...@gm...> - 2013-11-01 03:48:08
|
> The memory growth is observed in the program not gnuplot. This is the
> code
> that is being called periodically every few seconds. extents_plot_handler
> = gnuplot_init(); is only called once at some previous point.
>
> int i;
>
> char * cmd_header = "plot \"-\" matrix with image\n";
> char * cmd = malloc(
^^^^^^^^^^^^^^^
Why malloc() rather than realloc()?
>
> sizeof(char)
>
> * ((4 * extents_map_size)
>
> + (int) (extents_map_size / pixels_width) + 30));
>
> strcpy(cmd, "");
> cmd = concat(cmd, cmd_header);
^^^^^^^^^^^^^^^^^^^^^^
The concat() function is not standard C, so I don't know exactly
what it does. But at a guess, possibly not what you think it does.
Try using strcat() instead.
That's assuming you know for sure that there will not be a buffer
overrun.
Ethan
> for (i = 1; i <= extents_map_size; i++) {
>
> cmd = concat(cmd, addr_space_extents_array[i - 1]);
> if (i % pixels_width == 0) {
>
> cmd = concat(cmd, "\n");
>
> }
>
> }
> if (extents_map_size % pixels_width > 0) {
>
> for (i = extents_map_size;
>
> i
>
> < (extents_map_size + pixels_width
>
> - (extents_map_size % pixels_width)); i++) {
>
> cmd = concat(cmd, "0 ");
>
> }
>
> }
> if (extents_map_size % pixels_width > 0)
>
> cmd = concat(cmd, "\ne\ne");
>
> else
>
> cmd = concat(cmd, "e\ne");
>
> /*FILE *file;
>
> char file_name[20];
> sprintf(file_name, "temp_data%d.txt", temp_counter++);
> file = fopen(file_name, "a+");
> fprintf(file, "%s", cmd);
> fclose(file);*/
>
> fprintf(stderr,"extents_plot_handler size:
> %d\n",sizeof(extents_plot_handler));
>
> fprintf(stderr,"extents_plot_handler file size:
> %d\n",sizeof(extents_plot_handler->gnucmd));
>
> fprintf(stderr,"extents_plot_handler active plots:
> %d\n",extents_plot_handler->nplots);
>
> fprintf(stderr,"extents_plot_handler temporary files:
> %d\n",extents_plot_handler->ntmp);
>
> fprintf(stderr,"extents_plot_handler temp filename table size:
> %d\n",sizeof(extents_plot_handler->tmp_filename_tbl));
>
> gnuplot_cmd(extents_plot_handler, cmd);
> free(cmd);
>
> --
> View this message in context:
> http://gnuplot.10905.n7.nabble.com/Memory-overload-in-real-time-plotting
> -tp17795p17798.html Sent from the Gnuplot - User mailing list archive at
> Nabble.com.
>
> -------------------------------------------------------------------------
> ----- Android is increasing in popularity, but the open development
> platform that developers love is also attractive to malware creators.
> Download this white paper to learn more about secure code signing
> practices that can help keep Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clkt
> rk _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> Membership management via:
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
|
|
From: keghn <ke...@ne...> - 2013-12-04 20:28:36
|
Wow a c library that generates gnuplot plots!
Hello.
I got the example.c working on my Mint 14 mate 64 bit Linux system to work.
I down loaded the tar and uncompressed it into my home directory.
Did not have to cmake, make, or ./configure&&make&&sudo make install.
I just change to "home/keghn/gnuplot_i/test/" and type this in the
terminal:
gcc example.c -I. ../src/gnuplot_i.c -o example
ran it with:
./example
And in the "example.c" had to change few lines:
//#include "gnuplot_i.h"
#include "../src/gnuplot_i.h"
Thanks all
Cheers
keghn
--
View this message in context: http://gnuplot.10905.n7.nabble.com/Memory-overload-in-real-time-plotting-tp17795p17863.html
Sent from the Gnuplot - User mailing list archive at Nabble.com.
|
|
From: <ke...@ne...> - 2013-12-04 20:34:04
|
This is the place: http://ndevilla.free.fr/gnuplot/ And you want: Download gnuplot_i-2.11.tar.gz |
|
From: walter h. <wh...@bf...> - 2013-12-05 17:25:15
|
hi keghn, nice find, you can simple do: make tests NTL it works, but its not a library but an object file that you can use in your programms. re, wh Am 04.12.2013 21:28, schrieb keghn: > > Wow a c library that generates gnuplot plots! > > > Hello. > I got the example.c working on my Mint 14 mate 64 bit Linux system to work. > I down loaded the tar and uncompressed it into my home directory. > Did not have to cmake, make, or ./configure&&make&&sudo make install. > I just change to "home/keghn/gnuplot_i/test/" and type this in the > terminal: > > gcc example.c -I. ../src/gnuplot_i.c -o example > > ran it with: > > ./example > > And in the "example.c" had to change few lines: > > //#include "gnuplot_i.h" > #include "../src/gnuplot_i.h" > > Thanks all > Cheers > keghn > > > > > > -- > View this message in context: http://gnuplot.10905.n7.nabble.com/Memory-overload-in-real-time-plotting-tp17795p17863.html > Sent from the Gnuplot - User mailing list archive at Nabble.com. > > ------------------------------------------------------------------------------ > Sponsored by Intel(R) XDK > Develop, test and display web and hybrid apps with a single code base. > Download it for free now! > http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
|
From: <ke...@ne...> - 2013-12-05 19:00:47
|
On my linux system,
make test, make all, and make test/example did not work for me:-(
On all other company software "make" fails about 75% of the time.
"Cmake" fails 99% of the time. Just another layer of code that can go wrong and it dose!
./confiure&&make&&make install work 99% of the time.
My system package installer and sudo apt-get work 88% of the time.
I am so glad that in the doc they put the compile command. Most
of the time i have to go through failed make file and find all of stuff
i need to compile a program from the command line.
Cheers kommrad,
keghn
|