|
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
|