[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gnuplot-info
Subject:    Re: [Gnuplot-info] Fwd:  Memory overload in real time plotting
From:       Ethan A Merritt <EAMerritt () gmail ! com>
Date:       2013-11-01 3:47:57
Message-ID: 2345695.supRN8SAgc () stonelion
[Download RAW message or body]

> 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
> gnuplot-info@lists.sourceforge.net
> Membership management via:
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info

------------------------------------------------------------------------------
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.clktrk
_______________________________________________
gnuplot-info mailing list
gnuplot-info@lists.sourceforge.net
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic