in reply to Re: Windows Non-Paged Pool Memory Allocation
in thread Windows Non-Paged Pool Memory Allocation

This is meant to test the allocation. We have a few kernal leaks and want to detect the problem via an SNMP trap. I need to test that the trap will fire. So I need to run a program that will eat up a ton of non-paged windows memory to force the trap. I would rather not purchase a C compiler to run the test ... so I want to see if a perl module has already incorporated this OS specific function. Make sense?
  • Comment on Re^2: Windows Non-Paged Pool Memory Allocation

Replies are listed 'Best First'.
Re^3: Windows Non-Paged Pool Memory Allocation
by BrowserUk (Patriarch) on Oct 31, 2006 at 13:18 UTC

    Okay, but you are going to be out of luck. According to the docs, both those apis need to be called from code running at an IRQ level:

    Callers of ExAllocatePoolWithQuotaTag must be running at IRQL <= APC_L +EVEL. Callers of AllocateCommonBuffer must be running at IRQL = PASSIVE_LEVE +L.

    If you knew (or search) to locate the dll they are exported from, the you could attempt to call them using Win32::API, but unless you know a way to cause your Perl script to be called by the kernel as an IRQ handler, it isn't going to to work.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Actually, it isn't that difficult. For example the code here will consume from the NP Pool until it faults for ($i=1; $i<=7000; $i++) { for ($k=1; $k<=1000; $k++) { $hash->{$k}->{"a $i b $j"}="$j fish $i"; } print "$j $i $k\n"; } I just want to see if there is a way to do it directly instead of indirectly

        Hmm. Rather harder than you think apparently.

        All that code does is cause a large amount of ram to be allocated to the process--and in an unnecessarially convoluted way.

        If you want to grab a large chunk of ram, a simple @a = 1..1e8; does fine. The only problem with that is you are not sure exactly how much you are allocating.

        To control exactly how much you cause to be allocated, the simplest way I've found is:

        c:\test>p1 Perl> open RAM, '+<', \$ram; seek RAM, 1e9, 0; print RAM 'X'; print length $ram;; 1000000002 Perl>

        which will allocate 956.1 MB of uninitialise ram.

        However, if you look in the Task Manager in the "Kernel memory" box on the Performance tab, you'll see that the Nonpaged memory allocation is well under that number (just 14 MB on my system currently, with the script above still running). Memory allocated by Perl is not allocated from the non-paged memory pool.

        Non-paged memory is a scarce resource that is usually allocated in small numbers of single pages by device drivers.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Windows Non-Paged Pool Memory Allocation
by flake (Initiate) on Oct 31, 2006 at 15:08 UTC
    Umm, you can download many C or C++ compilers gratis.

    Even MS its self makes a free version of Visual C++ 2005 (which will compile C code also) though obviously you would not be getting source code there
      More specifically, MSFT makes the Windows Driver Kit available. Since the description claims it's a full build environment, I'm assuming that means it has the C compiler you'd need to write your deliberately anti-social driver.

      I haven't downloaded it to check, though :)


      Mike