From: Jagadeesh Bhaskar P <jbhaskar@hclinsys.com>
To: Ray Olszewski <ray@comarre.com>
Cc: Linux Newbie <linux-newbie@vger.kernel.org>
Subject: Re: malloc and free
Date: Sat, 25 Dec 2004 08:46:55 +0530 [thread overview]
Message-ID: <1103944615.3799.7.camel@myLinux> (raw)
In-Reply-To: <5.1.0.14.1.20041224104634.01f589e0@celine>
[-- Attachment #1: Type: text/plain, Size: 1825 bytes --]
Hi,
I have read that the malloc-ed memory is not actually freed upon
calling free, but is still maintained in the processes' malloc pool of
memory. So can that add to the memory leak attributing a segfault?
Please someone tell if I am wrong!!
On Sat, 2004-12-25 at 00:23, Ray Olszewski wrote:
> At 06:39 PM 12/24/2004 +0000, Ankit Jain wrote:
> >hi
> >
> >routine xyz uses malloc and free functions. it gives
> >accurate and correct result if called once.
> >
> >but if the function is called in a loop N number of
> >times then probably it gives segmentation fault.
> >
> >what is the reason? can any body guess or test code
> >is needed?
>
>
> Probably test code is needed. But if you want a guess ... the "free" call
> contains an error that leads to a memory leak. If you call the routine
> once, that's no big deal, and the routine will appear to return "accurate
> and correct result". But if you call it a lot, memory consumption goes up
> past the point where the kernel can support it and a segfault results.
>
> That's just a shot in the dark, though ... and even it assumes that N is a
> big number (thousands at least), not 10 or 20. Your use of "probably" does
> make it an appealing guess, though.
>
> Really, though, you are posing the question, "What can go wrong with
> malloc() and free()?" Put that way, it is obvious that it is too vagure for
> a troubleshooting list. Let's see the code, as well as whatever is calling
> the code.
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
--
With regards,
Jagadeesh Bhaskar P
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2004-12-25 3:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-24 18:39 malloc and free Ankit Jain
2004-12-24 18:53 ` Ray Olszewski
2004-12-25 3:16 ` Jagadeesh Bhaskar P [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-12-24 18:39 Ankit Jain
2004-12-24 18:52 ` Eric Bambach
2002-05-20 11:26 Sameer Maggon
2002-05-20 10:06 ` wwp
2002-05-20 18:16 ` Andrew Edmondson
2002-05-20 9:55 Alvarez Alberto-AALVARB1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1103944615.3799.7.camel@myLinux \
--to=jbhaskar@hclinsys.com \
--cc=linux-newbie@vger.kernel.org \
--cc=ray@comarre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.