C out-of-bound pointer question
    Dag-Erling Smørgrav 
    des at des.no
       
    Fri Nov 16 06:02:48 PST 2007
    
    
  
Oliver Fromme <olli at 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
-- 
Dag-Erling Smørgrav - des at des.no
    
    
More information about the freebsd-chat
mailing list