bug-gsl
[Top][All Lists]
Advanced

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

[Bug-gsl] memory leak problem with matrices


From: Sergey Plis
Subject: [Bug-gsl] memory leak problem with matrices
Date: Wed, 19 Sep 2007 09:53:19 -0600
User-agent: KMail/1.9.7

In order to see the memory not being freed compile the following program:
-------------------------------------------------------------------------
#include <stdio.h>
#include <gsl/gsl_matrix.h>
#include <curses.h>
int
main (void)
{
  int i, j;
  int c = 5000;
  initscr();
  cbreak();
  gsl_matrix * m[c];
  printw("press any key to allocate matrices...");
  getch();
  for (i = 0; i < c; i++) 
    m[i] = gsl_matrix_calloc (100, 100);
  printw("press any key to free the memory  ...");
  getch();
  for (i = 0; i < c; i++) 
    gsl_matrix_free (m[i]);
  printw("press any key to exit...             ");
  getch();
  endwin();
  return 0;
}

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

Run the program and look in the top what is happening to its memory. can be 
done in a separate terminal window with:
top -d 1 -p $(ps -A | grep a.out | sed -e 's/^ *//g'|sed -e 's/ .*//g')

Basically, the memory is not being freed. This is a very strange bug, because 
for some matrix sizes the memory is freed, for some it is not.

I have tried this little code snippet at Ubuntu Feisty and Gutsy with the same 
outcome. Feisty's gsl version is 1.8.3, Gutsy's is 1.9.

Can this be corrected?

Thanks!

--
Sergey




reply via email to

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