Click to See Complete Forum and Search --> : Memory problem-any help is appreciated


Kohinoor24
February 14th, 2003, 04:21 AM
Hi all,

Iam running an application which takes a Data File as input,formats the data & write it to an output File.I was running the application with 2MB data as input.Iam running it under both windows & Linux.

Under Linux,The memory usage shoots up and reaches a point where there is no more memory available & I have to reboot the system.

Iam using the same application with the same input under windows & there is no Memory usage shoot up.

This behaviour is showing up only in the linux system.

Threads are implemented in 2 different ways under windows & Linux.Is there any difference in stl implementation,memory management under Linux & thigs of that sort......which could be the cause.Iam just guessing all these things.

Iam just wondering what could be the cause of this problem under Linux.Any suggestion or opinion would be very much appreciated.

Elrond
February 14th, 2003, 05:05 AM
There are probably differences in the implementation and memory management in STL libraries, but both should as as safe, so the problem is probably not coming from there.

I don't know Linux enough to have any idea about the differences in the threading system.

PaulWendt
February 14th, 2003, 07:42 AM
I would try looking at the areas where you're allocating memory;
use of a profiler would help. Once you see these areas, try
commenting each successive area out until your program runs.
I'm guessing that there'll be one set of operations that you can
say "Oh, this is fine on Windows, but not good on Linux". Then
you can take appropriate actions.

It's hard to know what your specific problem is without specific
details; can you reproduce this in a sample program that you can
post here? If not, can you post the source? If it's just a
conversion program, it's hopefully small?

--Paul

Kohinoor24
February 14th, 2003, 07:49 AM
No paul,Its a pretty large program.I was just telling what it does in a single word as "Conversion program".I wont be able to reproduce it as I dont know what is the cause of this behaviour.Could I get any free software from the internet for checking ResourceLeaks under Linux.Like the "BoundsChecker" we have for windows.

Thanks
Kohinoor

akraus1
February 14th, 2003, 08:04 AM
There are environment variables which can be used to track the
malloc free calls. set MALLOC_CHECK_ to 1 or 2.

Recent versions of Linux libc (later than 5.4.23) and GNU libc (2.x) include a malloc implementation which is tunable via environment variables. When MALLOC_CHECK_ is set, a special (less efficient) implementation is used which is designed to be tolerant against simple errors, such as double calls of free() with the same argument, or overruns of a single byte (off-by-one bugs). Not all such errors can be proteced against, however, and memory leaks can result. If MALLOC_CHECK_ is set to 0, any detected heap corruption is silently ignored; if set to 1, a diagnostic is printed on stderr; if set to 2, abort() is called immediately. This can be useful because otherwise a crash may happen much later, and the true cause for the problem is then very hard to track down.

Another tool is mtrace from the glibc library. See docu for details.

dimm_coder
February 14th, 2003, 08:20 AM
I can suggest U the program which called "valgrind".
I use it for Linux programs and it really helps to find some problems.

write "valgrind" in Google

or

http://developer.kde.org/~sewardj/ - one of the links.

It can check memory leaks too and many other things.

Hope, it helps U.

Kohinoor24
February 17th, 2003, 01:52 AM
I have downloaded a file of type "valgrind-1.0.4.tar.bz2".How can I install it in my system.
How should I proceed with this file...

dimm_coder
February 17th, 2003, 03:38 AM
What's the problem? Like for common Linux/Unix application with source codes.
unzip it,
then
tar -xf <valgrind-package-name.tar>

then go into valgrind dir

and then

1) ./configure
2) make
3) make install
(read in INSTALL file)

then about its usage U can read in /docs folder.

Command will be something like:
(I use it)
valgrind -v --num-callers=10 --leak-check=yes --logfile-fd=10 10>logfile ./program [command line]

All this U can read in /docs/manual.html