c:\test>valloc Global Memory Status Total Physical:392956 pages Available Physical:309695 pages ## 1.5 GB physical with ~1.3 GB free Total PageFile:1048575 pages Available PageFile:1048575 pages ## 4 GB of pagefile all free Total Virtual :524256 pages Available Virtual :516124 pages ## 2 GB of Virtual Memory Available mostly free Allocated: 260000 pages [1064960000 bytes] at 280d0000 Allocated: 270000 pages [1105920000 bytes] at 280d0000 Allocated: 280000 pages [1146880000 bytes] at 280d0000 Allocated: 290000 pages [1187840000 bytes] at 280d0000 Allocated: 300000 pages [1228800000 bytes] at 280d0000 Allocated: 310000 pages [1269760000 bytes] at 280d0000 Allocated: 320000 pages [1310720000 bytes] at 280d0000 Not enough storage is available to process this command at c:\test\valloc.pl line 18, line 7. #### #! perl -slw use strict; #use Inline 'FORCE'; use Inline C => 'DATA', NAME => 'valloc', CLEAN_AFTER_BUILD => 0; use constant PAGE => 4096; my( $tPhys, $aPhys, $tPage, $aPage, $tVirt, $aVirt ) = globalMemoryStatus(); print <; virtualFree( $addr ) or die $^E; } __DATA__ __C__ #include void globalMemoryStatus ( ) { Inline_Stack_Vars; MEMORYSTATUS stat; GlobalMemoryStatus( &stat ); Inline_Stack_Reset; Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwTotalPhys / 4096 ) ) ); Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwAvailPhys / 4096 ) ) ); Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwTotalPageFile / 4096 ) ) ); Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwAvailPageFile / 4096 ) ) ); Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwTotalVirtual / 4096 ) ) ); Inline_Stack_Push( sv_2mortal( newSVuv( stat.dwAvailVirtual / 4096 ) ) ); Inline_Stack_Done; return; } U32 virtualAlloc( U32 size ) { return (U32)VirtualAlloc( NULL, (SIZE_T)size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE ); } U32 virtualFree( U32 a ) { return VirtualFree( (LPVOID)a, 0, MEM_RELEASE ); }