<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Aug 8, 2008 at 12:04 AM, Sergey Skorokhodov <span dir="ltr"><<a href="mailto:ucayalyfish@yandex.ru">ucayalyfish@yandex.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<div><div></div><div class="Wj3C7c"><br>
> Hello,<br>
><br>
> I have installed Ubuntu on a machine with following<br>
> config.<br>
><br>
> RAM :  2 GB<br>
> Machine:  Intel Core 2 Duo<br>
> OS:  Ubuntu 64 bit.<br>
> Disk:  250 GB.<br>
><br>
><br>
> I have attached a simple program to test memory allocation on linux<br>
> and something strange is happening.<br>
><br>
> 1.    If I invoke large_memory function then maximum<br>
>        size I am allowed is 245GB.<br>
><br>
> 2.    If I use less than 245GB  ( say 244 GB) then the<br>
>        second stage is also passed.  Where from OS is<br>
>        allocating 244GB ?<br>
><br>
> 3.   Strange enough, if I use chuck memory, I can<br>
>       goto 3817GB before I get segmentation fault.<br>
>       ( and buf == NULL is never reached ).<br>
><br>
> 4.   Much more strange, GoogleHeapProfiler, and<br>
>       ValGrindHeap profile also add to my uneasiness<br>
>       and report that 3817GB allocation is successful.<br>
><br>
> What is happening ? Please help.<br>
><br>
</div></div>I guess that the result of<br>
<br>
size_t nb       =       1024*1024*1024;<br>
nb              *=      255;    // 0x3FC0000000<br>
<br>
is much larger than the maximal value of size_t on 32-bit systems. So it<br>
is truncated silently to 4 GB. Try<br>
<br>
size_t nb = 1024*1024*1024*255;<br>
<br>
and you get a warning. C/C++ consider that the programmer knows what<br>
he/she is doing in the former case and keep silent but you can turn some<br>
more rigorous checking on if you like.<br>
<br>
Actually, a program is allocated with address space some less that 4 GB<br>
on 32-bit system as some address space is used for memory mapped io and<br>
other hardware needs.<br>
<br>
--<br>
Best regards,<br>
Serge<br>
<font color="#888888"><br>
<br>
--<br>
</font><div><div></div><div class="Wj3C7c">ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
</div></div></blockquote></div><br>Hello,<br><br>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<br>explanation of this behavior in the previous mail.  <br>
<br>Thanks<br></div>