Getting Out of Memory Exception when you have plenty of Memory/RAM available


This is a great article on why having or adding more memory won’t fix your Out of Memory Exception.   Bottom line.. on a 32bit server you’re site will crash when it hits between 600MB and 800MB.  The amount varies based on what else is going on with the machine.   The solution? Basically, you have to upgrade to a 64bit OS or re-write your application.


Why adding more memory won’t fix your Out of Memory error by Edge

Copied from the article directly, in case it ever goes down.


Here an interesting case. Consider there 2 scenarios:

Both are running the same website, both have the same amount of users connected.

Now imagine this website has a page to upload pictures, just like any regular photo-album website.

For some reason, at some point the users complain that they see an error page indicating out of memory error.

So, you wonder: How come? they are just uploading a photo to my website, and I still have plenty of memory in my server anyway.

Anyhow, you stop thinking about this and go for the easiest, quick and dirty solution: If the system tells me that my computer does not have enough memory then I just need to add more memory. Right?

And guess what? you still will get the error message.

That's a very common mistake. Having a machine with 10GB of memory does not mean you will have 10GB of memory available. I explain.

It does not matter if your computer or server has 512 MB, 1 GB, 2 GB, 4 GB or 8 GB of RAM. If your machine is a 32-bit machine it will only be able to see/manage 4 GB. That's mathematics, that's life, that's the way things are and you can't do nothing about it. A 32-bit machine can not do more than that.

Additional memory may increase your system performance, but it won't increase the memory availability. Sure your computer will use less the hard disk for swapping operations and will be able put more stuff in memory and start some programs faster, but 4GB is the limit; after this point the memory management module will start doing disk swap and to use the famous page file.

And here comes more bad news: Your Windows system on a 32-bit machine requires 2 GB allocated only for it.

So, if you have 4 GB installed, effectively you will have 2 GB only for applications; your windows will be using alone 2 GB.

So, what does out of memory means?

Well, according to some people at Microsoft, this limit for an average configuration is reached between 600 MB and 800 MB of utilization. That 800 number is NOT A RULE, is a baseline. Generally speaking the largest majority of configurations with website, .NET and SQL Server database might have a problem around this point. Of course, this can vary from system to a matter of fact a system can be out of memory at just 600 MB.

Yes, it does sounds crazy. You look so happy now that you just bought a 4GB RAM notebook and your computer is breaking with just 800MB, hun?

Here is another point for you. Have you ever seen someone bragging that he/she bought a 10-megapixel camera and now he/she believes their pictures are going to be better because of this?

Well, guess what? Just like the number of megapixels in a camera box does not have much to do with picture quality, RAM memory does not have much to do with hard disk space.

That's a common mistake: People buy RAM as if they were buying a hard disk.

RAM usage needs to me continuous, unlike hard disk. A simple 5MB Microsoft Word document when saved in a hard disk can be split up in hundreds of pieces; When you open this file in memory, the RAM requires those 5MB to be allocated continuously.

Can you see now the reason for the 'out of memory' message?

Yes, it really means 'there is not enough continuous memory to place that file in memory'. Your system might have 2GB of RAM but unfortunately it might be too busy with stuff running and there is no enough continuous memory to put the picture you are uploading.

Yeah, you can not do much but you can buy a 64-bit machine then when you add more memory you can really use it more efficiently. And yes, we have Microsoft Windows systems for 64-bit machines.

If you do not want to buy a new system of upgrade you current server to a better version then you should think other solutions in the business process, such as to avoid users upload pictures with more than 1 MB in size to be uploaded.

The Add-in ‘xxxx' failed to load or caused an exception in SQL Management Studio


And clicking on Yes to remove it, doesn’t help.  This is actually a permission issue from Vista and Windows 7 and up.


The service pack update to Windows Vista has been known to change permissions to the registry in a way that prevents user access to the information about installed classes: HKEY_CLASSES_ROOT. This prevents SQL Server Management Studio from loading the add-ins into the environment.

To correct this problem, it's necessary to assign permissions to the registry for the logged-in user.

  1. First open the Registry Editor (regedit.exe) using the "Run As Administrator" option.
  2. Right-click HKEY_CLASSES_ROOT and select "Permissions", and give the logged-in user full control.
  3. The following permissions needed to be added to HKEY_CLASSES_ROOT as well:
           -Users: read
           -System: full control
           -CREATOR OWNER: full control on subkeys only

Adobe Encore CS5 cannot run in non-royalty serialized mode. The Application needs to be serialized with a royalty bearing serial number. Or Indesign does not have proper serial.


If you happen to get this issue with your CS5, I’ve found a solution.

Basically what happen is that Adobe Encore accepts only special serial numbers and it wont accept our Master Serial all the time. If this happens you need to use this simple fix:

  • Just copy and paste the “amtlib.dll” to your C:/Program Files/Adobe/Adobe Encore CS5 folder. When asked select “Copy and Replace” and it will work properly.
    Do this only for Encore and DO NOT replace other original amtlib.dll’s
  • If this do not work try to reactivate Encore CS5 with Encore serial that I provided below (1132-1127-8739-4724-1356-4304) You can do from Encore Help panel in the main Encore menu after you open Encore
  • If this doesn’t work perhaps you need to change the main Adobe CS5 Master Collection serial number by deactivating the whole CS5 suite and activating again with different serial.
  • You need to still remember to follow all the safety procedures when doing it so (being disconnected from the internet, fixing your host file and blocking Encore with firewall)


Download File: amtlib.dll
You can use this for Encore or Indesign CS5 Master Collection

Slow Remote Desktop

These are the commands I ran to speed up Remote Desktop. Article is for Vista, but it applies to Windows 7 as well.  Run commands locally even if it’s just a particular server that is slow. Which makes you think it’s that server and not your machine.

Not sure if it applies to XP.

- Run a command prompt (cmd.exe) as an Administrator
- Type: netsh interface tcp set global autotuninglevel=disabled
Disable the autotunning feature in Vista completely, and fit and lock the RWIN receive window to default value 65536 bytes.
If you want to to re-enable it:
- Type: netsh interface tcp set global autotuninglevel=normal
In some cases you may need to use this command in addition to the above, but I didn't have to:
- Type: netsh interface tcp set global rss=disabled
Update! This command makes your network connection EVEN FASTER
Type: netsh interface tcp set global autotuninglevel=highlyrestricted
The reason is that this command will still "auto tune" your TCP connections, but not as drastically as 'normal' mode. It will allow the receive window to grow beyond the default value, but again it will do so very conservatively.


VS 2010 Low Virtual Memory Fix – Insufficient available memory


Man VS 2010 is a memory hog.  Well heck even 2k8 was too, but at least it always let me copy/paste.

After awhile I lose the ability to copy text from my code. With a warning saying “Insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try again later.”


Found this post to increase the Virtual Memory:

However, they have a typo in the command.

If you run their command: bcdedit /set IncreateUserVa 3072 it fails with a “The element data type specified is not recognized, or does not apply to the specified entry.” error.

Run the proper command: bcdedit /set IncreaseUserVa 3072 and you get “The operation completed successfully.

I don’t this will remove the error, just give me more time before it happens.  Supposedly, 64bit doesn't have this problem.

HTTP Error 404.17

HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.

One Possible Solution:

%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

Windows 7 Genuine Validation Fails on Genuine Install


I was having problems trying to download XPMode because the website tries to validate your Windows 7 operation system.  Even though I activated successfully and I ran the MGA Diagnostic Tool locally and it said Genuine. It still failed the online check.


I even called Microsoft to see if they could figure it out. No luck. They tried the obvious stuff, re-entering my product key, re-activating.  They couldn’t figure it out. Even gave me a new product key and still no luck.  Then I told them I had to go.

Found the answer on my own..

I was getting Event Errors in my Application Log.

Source: CAPI2
Event ID: 257

The Cryptographic Services service failed to initialize the Catalog Database. The ESENT error was: -1011.

Then I caught online something on bypassing XP Genuine has to do with the Cryptographic services. Putting two and two together, I figured this error was the source of my problem.

After a little digging I found this article which gave me steps to wipe out my System Catalog Database. 

This fixed my error and allowed me to validate my windows online.

  1. Click Start, point to Administrative Tools, and then click Services.
  2. Right-click Cryptographic Services, and then click Stop.
  3. Click Start, and then click Computer.
  4. Navigate to %systemroot%\System32.

    By default, %systemroot% is located at C:\Windows.

  5. Rename the catroot2 folder to catroot2.old.
  6. In the Services snap-in console, right-click Cryptographic Services, and then click Start.

Silverlight & WCF Debugging and using Fiddler!


Fiddler2 Best program out there I think for debugging WCF errors in silverlight when you get “NotFound” error messages.


Example. I had a Silverlight application where I had to enable it work over https and change the host headers. As many of you may know, WCF on .NET 3.5 you can not bind to website with multiple headers. You have to hardcode the WCF Address in the web.config. (I’ve read that .Net 4.0 will allow this but still not for ssl).

All my setting from what I can tell in my web.config and my clientConfig were correct, and the app worked fine in http mode only, however I would get the most generic message ever.


This is my custom error window I use to have users send the errors to the server.  As you can see the error is “The remote server returned an error: NotFound.”  this is basically the equivalent of the old server error message “An Unexpected Error Occurred”.  Basically who knows. Something’s wrong.  The WCF service is not responding. Could be your firewall, your IIS, your service is erroring out or 100 other things. 

Download and install Fiddler2 and let the magic begin.  I did try WebDevHelper which is like FireBug for FireFox but it works in IE.  It’s pretty good, but like FireBug, doesn’t give you that WCF error.

Loading up Fiddler, I can inspect the traffic and actually see the .Net error. It even highlights it in red for me.  (Had to block out the app names).


From this I was able to expand the information like below to see the real error message.


Cannot be process at the receiver, due to an AddressFilter mismatch at the EndpointDispatcher.  Check that the sender and receiver’s EndPointAddresses agree

After I realized what the problem was I was able to fix my service by adding the attribute AddressFilterMode:=AddressFilterMode.Any to my WCF class.

<ServiceContract(Namespace:="")> _
<ServiceBehavior(IncludeExceptionDetailInFaults:=True, AddressFilterMode:=AddressFilterMode.Any)> _
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class xxxxxxxxxxxService


Problem Solved.


WCF logging:

You can also log all your WCF Traffic to a Log file on your server.

          <add name="WcfListener"
          <!-- switchValue attribute has no impact on MessageLogging -->
          <source name="System.ServiceModel.MessageLogging">
                  <add name="WcfListener" />
          <source name="System.ServiceModel"
                        switchValue="Warning, ActivityTracing"
                        propagateActivity="true" >
                  <add name="WcfListener" />




Other useful posts..

Silverlight and WCF – WCF Logs and Debugging

Service Trace Viewer Tool (SvcTraceViewer.exe)

Silverlight & WCF - HTTPS

IIS7 Windows7/Server2008 ApplicationPoolIdentity Security Change from Network Service


Yeah this one got me..

The change microsoft made to have AppPool now run as “ApplicationPoolIdentity” instead of Network service.

So if you normally give Network Service rights needed to your webapp, you now have to stop doing that and change it to

IIS AppPool\DefaultAppPool



End of that.





  1. Open Windows Explorer
  2. Select a file or directory.
  3. Right click the file and select "Properties"
  4. Select the "Security" tab
  5. Click the "Edit" and then "Add" button
  6. Click the "Locations" button and make sure you select your machine.
  7. Enter "IIS AppPool\DefaultAppPool" in the "Enter the object names to select:" text box.
  8. Click the "Check Names" button and click "OK".

By doing this the file or directory you selected will now also allow the "DefaultAppPool" identity access.

EventID 4625 on Windows 2008 IIS7 Windows Authentication Error

I was having wierd authentication issues on a Windows 2008 server with IIS7. I was trying to use Windows Authentication.  Worked fine from a remote location but failed when local on the server.

An account failed to log on.

    Security ID:        NULL SID
    Account Name:        -
    Account Domain:        -
    Logon ID:        0x0

Logon Type:            3

Account For Which Logon Failed:
    Security ID:        NULL SID
    Account Name:        xxxxxx
    Account Domain:        xxxxxx

Failure Information:
    Failure Reason:        An Error occured during Logon.
    Status:            0xc000006d
    Sub Status:        0x0

Process Information:
    Caller Process ID:    0x0
    Caller Process Name:    -

Network Information:
    Workstation Name:    xxxx-xxxxxx
    Source Network Address:    ###.###.###.###
    Source Port:        49597

Detailed Authentication Information:
    Logon Process:       
    Authentication Package:    NTLM
    Transited Services:    -
    Package Name (NTLM only):    -
    Key Length:        0

This event is generated when a logon request fails. It is generated on the computer where access was attempted.

The Subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.

The Logon Type field indicates the kind of logon that was requested. The most common types are 2 (interactive) and 3 (network).

The Process Information fields indicate which account and process on the system requested the logon.

The Network Information fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.

The authentication information fields provide detailed information about this specific logon request.
    - Transited services indicate which intermediate services have participated in this logon request.
    - Package name indicates which sub-protocol was used among the NTLM protocols.
    - Key length indicates the length of the generated session key. This will be 0 if no session key was requested

I found the solution on the MS Support site, Q89681.  Which suggested to turn off the LoopbackCheck.

To set the DisableLoopbackCheck registry key yourself, follow these steps:

  1. Set the DisableStrictNameChecking registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:

    281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name

  2. Click Start, click Run, type regedit, and then click OK.
  3. In Registry Editor, locate and then click the following registry key:


  4. Right-click Lsa, point to New, and then click DWORD Value.
  5. Type DisableLoopbackCheck, and then press ENTER.
  6. Right-click DisableLoopbackCheck, and then click Modify.
  7. In the Value data box, type 1, and then click OK.
  8. Quit Registry Editor, and then restart your computer.