Can some throw bright light on Linux Memory Allocation
MirJafar Ali
mirjafar2008 at gmail.com
Thu Aug 7 19:22:58 UTC 2008
On Fri, Aug 8, 2008 at 12:04 AM, Sergey Skorokhodov
<ucayalyfish at yandex.ru>wrote:
> Hi,
>
> > Hello,
> >
> > I have installed Ubuntu on a machine with following
> > config.
> >
> > RAM : 2 GB
> > Machine: Intel Core 2 Duo
> > OS: Ubuntu 64 bit.
> > Disk: 250 GB.
> >
> >
> > I have attached a simple program to test memory allocation on linux
> > and something strange is happening.
> >
> > 1. If I invoke large_memory function then maximum
> > size I am allowed is 245GB.
> >
> > 2. If I use less than 245GB ( say 244 GB) then the
> > second stage is also passed. Where from OS is
> > allocating 244GB ?
> >
> > 3. Strange enough, if I use chuck memory, I can
> > goto 3817GB before I get segmentation fault.
> > ( and buf == NULL is never reached ).
> >
> > 4. Much more strange, GoogleHeapProfiler, and
> > ValGrindHeap profile also add to my uneasiness
> > and report that 3817GB allocation is successful.
> >
> > What is happening ? Please help.
> >
> I guess that the result of
>
> size_t nb = 1024*1024*1024;
> nb *= 255; // 0x3FC0000000
>
> is much larger than the maximal value of size_t on 32-bit systems. So it
> is truncated silently to 4 GB. Try
>
> size_t nb = 1024*1024*1024*255;
>
> and you get a warning. C/C++ consider that the programmer knows what
> he/she is doing in the former case and keep silent but you can turn some
> more rigorous checking on if you like.
>
> Actually, a program is allocated with address space some less that 4 GB
> on 32-bit system as some address space is used for memory mapped io and
> other hardware needs.
>
> --
> Best regards,
> Serge
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
Hello,
In the very first mail, I had mentioned that I have installed 64 OS, so I
dont think that this was the issue. But I received good
explanation of this behavior in the previous mail.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20080808/4c5a674b/attachment.html>
More information about the ubuntu-users
mailing list