Re: kernel memory issue using malloc()

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

 



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

--
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