Re: kernel memory issue using malloc()

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

 



On Sun, 11 Feb 2007 15:12:40 -0800 Mounir Bakkali wrote:

> Nish Aravamudan wrote:
> > On 2/11/07, Mounir Bakkali <mounir.bakkali@xxxxxxxxx> wrote:
> >> Well the kernel manages the memory and malloc makes a kernel call
> >> to give you or not the amount of memory requested... so it is a kernel
> >> issue and therefore my question fits totally in here.
> >
> > 1) Don't top-post.
> >
> > 2) The kernel also manages your filesystem and your hard drives. That
> > doesn't make asking about why your hard drive is out of space a kernel
> > issue.
> >
> >> Moreover, I found this on wikipedia:
> >>
> >>
> >>       "Allocation failure
> >>
> >> |malloc| is not guaranteed to succeed — if there is no memory available,
> >> or if the program has exceeded the amount of memory it is allowed to
> >> reference, |malloc| will return a |NULL| pointer. "
> >
> > Ahem, someone else already pointed this out to you on the list. And
> > it's in the man-page which is where you should look for programming
> > information.
> >
> >> And I am not in these 2 cases so the kernel should be able to allocate
> >> 256 bytes while I have nearly
> >> 800 Mega bytes of free memory.
> >> The thing I cannot figure out is why it is working with 512 (which is
> >> bigger than 256....obviously
> >> it can allocate more memory but not less???) and not with 256.
> >>
> >> There is something though I forgot to mention. The program is allocating
> >> 256 bytes for about
> >> 2500 times but the segmentation fault appears about the 2000th
> >> allocation and I know that later on
> >> there will be a segmentation fault because later on I need 376 bytes
> >> (after the 2050th allocation)
> >> and I know that at that time there will be a segmentation fault.
> >>
> >> So my question is: why is this segmentation fault appears after the
> >> 200th and not after the 2000th allocation?
> >
> > You just said it happens after the 2000th time. Show us the code and
> > the exact problem, if you want any help. But again, this is not a
> > problem for discussion on this list.
> >
> >> Does it have to do with some kind of locking features and memory of the
> >> kernel? Can it be a scheduling issue?
> >
> > This is a list for asking about kernel *development*. Not userspace
> > programming issues.
> >
> > This is not to say you may not have run into a kernel bug. But it
> > seems highly unlikely, as malloc() is so widely used and no one else
> > is complaining.
> >
> > Thanks,
> > Nish
> >
> 
> 1) You answers do not help at all Nish. Talking around the topic do not 
> help.
> 
> 2) Nish, I am not complaining about anything. I am just trying to understand
>     and eventually to help the open-source industry.
> 
> 3) memory management is a hot topic regarding the linux kernel.

Sure, but so far your example is a userspace problem, most likely
glibc.

> 4) For you Nish exclusively: Being nice does not require much effort
>     so please, do not answer reply regarding this topic since it looks like
>     you prefer to talk around the topic instead of helping.
> 
> 5) Kernelnewbies: I apologize for this email. I don't like to write such 
> email
>     but I had to because of that Nish guy.
>     Please if anyone has any idea, especially if it is really a kernel 
> issue, feel
>      free to post it in here.

As already suggested, try to use gdb to find the fault.

And at last post a full example program so that other people
can try it out.

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux