Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Nov 2007 14:47:26 +0100
From:      =?utf-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@des.no>
To:        freebsd-chat@FreeBSD.ORG
Subject:   Re: C out-of-bound pointer question
Message-ID:  <861waql2tt.fsf@ds4.des.no>
In-Reply-To: <200711160756.lAG7uGA1017136@lurza.secnetix.de> (Oliver Fromme's message of "Fri\, 16 Nov 2007 08\:56\:16 %2B0100 \(CET\)")
References:  <200711160756.lAG7uGA1017136@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Oliver Fromme <olli@lurza.secnetix.de> writes:
> It is true that the k[] array in v2.0 uses 1 GB of mapped memory,
> *BUT* it does not use 1 GB of RAM.  It only uses one page of physical
> RAM.  Remember that RAM is allocated dynamically when it is accessed
> for the first time, so if you never access k[0..268435409], then no
> RAM will be allocated for it.  Of course, you should make sure that it
> is a local variable (or a malloc()ed one) that is not initialized, or
> otherwise the initialization will cause RAM to be allocated.  Make
> sure you initialize only the indices that you need.

It can't be a local variable; it's larger than the stack.

DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?861waql2tt.fsf>