[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libipfwc memory leak?
From: |
Andriy T . Yanko |
Subject: |
libipfwc memory leak? |
Date: |
Tue, 24 Sep 2002 14:31:21 +0300 |
Hi people!
I know that this letter is not for this mailllist. But I'm tired to find
mistake.
I just writen this smal code for example:
--- cut main.c ---
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <mcheck.h>
#include "libipfwc/libipfwc.h"
int main( int argc, char **argv)
{
pid_t pid;
unsigned int num_chains;
unsigned int num_rules;
static struct ipfwc_fwchain *chains;
struct ipfwc_fwrule *rules;
pid=fork();
if ( pid == -1 ) { printf("Can't fork!\n"); exit(0); }
if ( pid != 0) exit(0);
setsid();
mtrace();
while(1)
{
chains=ipfwc_get_chainnames(&num_chains);
rules=ipfwc_get_rules(&num_rules,0);
sleep(1);
}
muntrace();
return 0;
}
--- end ---
gcc -Wall -o test5 main.o libipfwc/libipfwc.o
export MALLOC_TRACE=log
./test5
mtrace test5 log:
Memory not freed:
-----------------
Address Size Caller
0x00000080 0 at /usr/src/asplinux/BUILD/glibc-2.2.4/libio/iofopen.c:50
0x0804b558 0xb0 at /usr/src/asplinux/BUILD/glibc-2.2.4/csu/init.c:0
0x0804b610 0x16c at /usr/src/asplinux/BUILD/glibc-2.2.4/libio/iofopen.c:50
0x0804b780 0x16c at /usr/src/asplinux/BUILD/glibc-2.2.4/libio/iofopen.c:50
.............................................................................................
When program is runnig I just type command "ps aux"
and I saw that my program get more and more system memory.
Is this memory leak of libipfwc library or glibc library?
In libipfwc.c function ipfwc_get_chainnames & ipfwc_get_rules use malloc()
but not use free().
But mtrace show function from glibc.
It's maybe ok for program ipchains but in my case is not gut.
How to fix it?
THANKS IN ADVANCE.
--
Andriy T. Yanko
address@hidden
* Avoid The Gates of Hell use Linux
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- libipfwc memory leak?,
Andriy T . Yanko <=