views:

1423

answers:

3

We have some Win32 console applications running on Windows Server 2003 Service Pack 2 that regularly fail with this:

Error 1450 (ERROR_NO_SYSTEM_RESOURCES): "Insufficient system resources exist to complete the requested service."

All the documentation we've found suggests it is linked to the number of Free System Page Table Entries running out. We have 16GB RAM in these machines and use the /3GB Operating System switch to squeeze the Windows kernel into 1GB and allow our processes access to 3GB of address space. This drastically reduces the total number of Free System Page Table Entries, so combined with our heavy use of MapViewOfFile() it is perhaps not surprising that the kernel page table entries are running out.

However, when using Performance Monitor to view the Free System Page Table Entries counter, the value is around 36,000 on reboot and doesn't go down when our application starts. I find it hard to believe that our application, which opens many large memory-mapped files, doesn't have any effect on the kernel page table. If we can't believe the counter, it's much more difficult to test the effect of any system changes we make.

There is a promising Knowledge Base article, The Performance tool does not accurately show the available Free System Page Table entries in Windows Server 2003, but it says the problem has been fixed in Service Pack 1, and we are already on Service Pack 2.

Has anyone else struggled with or solved this issue?

Update: I have checked !sysptes in windbg (debugging the kernel) and the value matches the performance counter, around 36,000. I guess this is most likely to mean that there really are that many free page table entries and Windows is telling the truth. It does leave the question of why we're getting 1450 errors though, if the PTEs are not running out.

Further update: We never did get to the bottom of why the 1450 errors were occurring. However, instead we upgraded the OS on these servers to 64-bit Windows. This allows the existing 32-bit applications (without recompilation) to access a full 4GB of virtual address space, and lets the kernel memory area with those pesky Page Table Entries be as big as it likes too. I don't think we've had a 1450 error since.

+1  A: 

Can you try the windbg command "!sysptes" to get System PTE Information? I'm not sure if you can do this with live kernel debug, you may have to get a memory dump.

Adam Mitz
We did investigate getting a kernel debugger working, and I _think_ we got as far as doing either the !sysptes or the !vm command. If I remember correctly they numbers did match the performance counter (which was a bit of a disappointment), but I'm hazy on the details. Thanks for answering.
Paul Stephenson
No problem, thanks for commenting..
Adam Mitz
A: 

I'm not sure why you assume that ERROR_NO_SYSTEM_RESOURCES is caused only by running out of free System Page Table Entries ? As far as I know, such generic error codes are used for more than one resource type. And in fact, the first Google hit suggests that running out of file cache memory may cause it too. (KB on an XP bug, which tripped this error mode).

In your case, I'd be checking the "Handle Count". Another possible problem is address space fragmentation. If you you want to create a 1GB file mapping view, you need 1GB of free address space, and it has to be contiguous. If you map a 1GB file, a 800 MB file, and a 1GB file, close the 800MB one and open a 900MB file, the 900MB file may not fit in the hole that's left.

MSalters
Thanks MSalters. I'll look at the Handle Count. We've encountered address space fragmentation before, but that usually results in error 8. One reason for my confusion over Free PTEs is that I'm sure on a previous versions of Windows it _did_ go down significantly when our app ran up.
Paul Stephenson
A: 

MS has 2 ways to allow there 32 bit OS to "deal" with hardware that has 4 GB or more of RAM.

Option 1: is what you did with the /3GB Switch in the Boot.ini.

Option 1 Pros and Cons:

(CONS) This option sucks 1 GB from the normal 2 GB kernel area - hence making the OS struggle to meet the demands of both Paged Pool allocations and kernel stack allocations. So a person might think that using the /3GB Switch will help their, but really this option is screwing the 32 bit Window OS into a slow death.

(CONS) But, This gives my App 3GB.... WRONG (Hence this is a CON) The catch is that ONLY application that have been recompiled from the vendor to be "/3GB Switch aware" can really use the extra 1 GB. Hence the whole use of the /3GB Switch is a really BAD J.O.K.E on everyone.

Read this link for a much better write-up:

http://blogs.technet.com/askperf/archive/2007/03/23/memory-management-demystifying-3gb.aspx

Option 2: Use the /PAE switch in the Boot.ini.

Option 2 Pros and Cons:

(PROS) This really this only option if you have a more then 4GB of RAM. It tricks a application by placing the complete application memory footprint in RAM. Normally, only a application "Working Set" memory is in RAM and the remaining application memory requirements go into Windows Pagefile. What is a application total memory requirements?? - it called "Virtual Size".

In my world, I have a big fat Java based IBM Product that I deal with. The server that is running the "application" has 16 GB of RAM. I simply add the /PAE switch and watch (thanks to sysinternals Processes Explorer) application paging requests go from 200 KB per sec to up to 4MB per sec.

Question: "Why"?

Answer: The whole application is in RAM.

Question: "Does the application know that it is completely running in RAM?

Answer: No - It is running that same old way that it was always run, "THINKING" that it's has part of itself as the "Working Set" memory living in RAM and the remaining application memory requirements go into Windows Pagefile.

Yes, it is that flipping GOOD.

Please Note: Microsoft has done a poor job telling anyone about the great Windows OS option. Duh

Try it and report back to stackoverflow....

Thanks for your answer brentmorrisrtp. The /3GB switch was needed for us because it was the address space we needed, not just use of extra physical RAM. It was our own app so we could recompile with /LARGEADDRESSAWARE, so your con wasn't a problem for us either. We do use the /PAE switch as well, if I remember correctly.
Paul Stephenson