bug-gsl
[Top][All Lists]
Advanced

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

Re: [Bug-gsl] memory leak problem with matrices


From: Sergey Plis
Subject: Re: [Bug-gsl] memory leak problem with matrices
Date: Wed, 19 Sep 2007 16:31:28 -0600

Thank you for the reply. 

Unfortunately this is not the case. Here is a standard version (no
curses):
------------------------------------------------------------------
#include <stdio.h>
#include <gsl/gsl_matrix.h>
int
main (void)
{
  int i, j;
  int c = 5000;

  gsl_matrix * m[c];

  printf("press any key to allocate matrices...");
  getchar();

  for (i = 0; i < c; i++) 
    m[i] = gsl_matrix_calloc (100, 100);

  printf("press any key to free the memory  ...");
  getchar();

  for (i = 0; i < c; i++) 
    gsl_matrix_free (m[i]);

  printf("press any key to exit...             ");
  getchar();

  return 0;
}

// compile with :
// gcc -L/usr/local/lib test.c -lgsl -lgslcblas -lm
------------------------------------------------------------------

Here how it looks in sequence of execution:
1. 
Program output:
press any key to allocate matrices...
Top output:
PID USER   PR  NI  VIRT  RES  SHR S %CPU %MEM  TIME+ COMMAND            
20361 pliz 16   0  3736  580  460 S    0  0.0  0:00.00 a.out  

2. 
Program output:
press any key to free the memory  ...
Top outputs:
PID USER   PR  NI  VIRT  RES  SHR S %CPU %MEM  TIME+ COMMAND
20361 pliz      20   0  385m 382m  524 S    0 19.0   0:00.63 a.out

3. 
Program output:
press any key to exit...             
Top output:
PID USER   PR  NI  VIRT  RES  SHR S %CPU %MEM  TIME+ COMMAND
20361 pliz      18   0  385m 382m  536 S    0 19.0   0:00.64 a.out 

As you can see it is 385m of memory not de-allocated - not simple
auxiliary structures.

--
Sergey





reply via email to

[Prev in Thread] Current Thread [Next in Thread]