Re: Small patch to show only memory usage.



On Mon, 22 Jan 2001, R. Bernstein wrote:

> In the patch, I added a single new function:
> 
> void     g_mem_summarize (const gchar *msg, gboolean show_alloc_size, 
> 			  gboolean show_large_alloc, gboolean show_alloc,
> 		          gboolean show_freed, gboolean show_used);
> 
> which has booleans for each of the pieces of the output for the
> existing routine, g_mem_profile(void). g_mem_profile then is just a
> call to this new routine which setts all of the parameters to
> TRUE. 
> 
> Another possible interface would be to have just one parameter which
> is interpreted as bit vector. One would also have to define a bunch of
> bitmasks to allow each of the pieces analogous to be used. This is
> similar say to the way the C lib 2 open() routine works with O_APPEND,
> O_CREAT and so on.

ok, i'm basically in favour of such a specialized function, however, it
definitely needs to operate on a bit-vector to keep up with future demands
(and to make the current API more sensible).

> R. Bernstein
> rocky panix com


> --- glib-orig.h	Thu Mar 23 21:34:01 2000
> +++ glib.h	Sat Jan  6 09:18:27 2001
> @@ -1366,8 +1366,11 @@
>  
>  #endif /* !USE_DMALLOC */
>  
> -void	 g_mem_profile (void);
> -void	  g_mem_check   (gpointer  mem);
> +void	   g_mem_profile   (void);
> +void     g_mem_summarize (const gchar *msg, gboolean show_alloc_size, 
> +				   gboolean show_large_alloc, gboolean show_alloc,
> +							        gboolean show_freed, gboolean show_used);
> +void								 g_mem_check     (gpointer  mem);
>  
>  /* Generic allocators
>   */
> 
> 
> --- gmem-orig.c	Fri May 19 03:25:05 2000
> +++ gmem.c	Sat Jan  6 09:59:53 2001
> @@ -415,16 +415,27 @@
>  
>  #endif /* ! USE_DMALLOC */
>  
> -
>  void
>  g_mem_profile (void)
>  {
> +  g_mem_summarize(NULL, TRUE, TRUE, TRUE, TRUE, TRUE);

put spaces before opening paranthesis.

> +}
> +
> +void
> +g_mem_summarize (const gchar *msg, gboolean show_alloc_size, 
> +			 gboolean show_large_alloc, gboolean show_alloc,
> +				   gboolean show_freed, gboolean show_used)

we use argument alignment so each argument needs to go on a new
line with their distinct names column aligned. if you move to bit vector
that shouldn't be an issue anymore though ;)

and, i'm not too constrained about keeping source compatibility with
g_mem_profile(), it's effect and implementation have vastly changed
anyways, so just make it take the bit vector right away (and please
prefix the individual values correctly with G_MEM_).

> +{
>  #ifdef ENABLE_MEM_PROFILE
>    gint i;
>    gulong local_allocations[MEM_PROFILE_TABLE_SIZE];
>    gulong local_allocated_mem;
>    gulong local_freed_mem;  
[...]

the rest looks pretty fine, awaiting resubmission ;)

---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]