Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^4: Map a string to an array

by BrowserUk (Pope)
on Nov 02, 2013 at 10:23 UTC ( #1060920=note: print w/ replies, xml ) Need Help??

in reply to Re^3: Map a string to an array
in thread Map a string to an array

(And BTW, congratulations on being able to work with a system having at least 128 Terabytes of system RAM — or do I misinterpret the reference address of 0x7ffafc013bf8?)

With virtual memory, heap does not have to be contiguous.

This C program allocates a single page of memory starting at the 4GB base address and then doubles the base address each time until it fails:

#define _CRT_SECURE_NO_WARNINGS #include <windows.h> #include <conio.h> #include <time.h> #include "debug.h" #include "mytypes.h" int main( int argc, char **argv ) { U64 size = 4096, base = 4294967296; char *p; while( 1 ) { char *p = VirtualAllocEx( GetCurrentProcess(), (VOID*)base, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ); DIEIF( p == NULL ); printf( "4k allocated at:%16p (%30I64d)\n", p, 0+p ); _getch(); base *= 2; } exit( 0 ); }

I only have 8GB of ram, but the last time the above succeeds:

C:\test>vmem3 4k allocated at:0000000100000000 ( 4294967296) 4k allocated at:0000000200000000 ( 8589934592) 4k allocated at:0000000400000000 ( 17179869184) 4k allocated at:0000000800000000 ( 34359738368) 4k allocated at:0000001000000000 ( 68719476736) 4k allocated at:0000002000000000 ( 137438953472) 4k allocated at:0000004000000000 ( 274877906944) 4k allocated at:0000008000000000 ( 549755813888) 4k allocated at:0000010000000000 ( 1099511627776) 4k allocated at:0000020000000000 ( 2199023255552) 4k allocated at:0000040000000000 ( 4398046511104) [ 1916] vmem3.c(18):p == NULL failed with error 87 (The parameter is incorrect)

It allocated a page at a base address that is 4096 GB. At that point the process is only using 668k of memory.

4096GB is 2^42 which reflects that my 64-bit processor actually only has a 44-bit virtual address space.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
Comment on Re^4: Map a string to an array
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060920]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2016-05-04 04:47 GMT
Find Nodes?
    Voting Booth?