#! 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 ); }