none
Failed to allocate a managed memory buffer of 268435456 bytes. RRS feed

  • Question

  • Hi,

    I have read in some forums that we could set transfer mode from Buffered to Streamed but I want keep Message Security which does not seem possible in streamed mode.

    I personally do not understand why the error message mention 256MB when all WCF configurations that I have read about points to 2GB. The exact error message is "Failed to allocate a managed memory buffer of 268435456 bytes. The amount of available memory may be low." You will find the exact binding configurations below.

    Binding (Client side):

    <customBinding>
            <binding name="CustomBinding_ProjectDesign" closeTimeout="01:00:00"
              openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
              <reliableSession acknowledgementInterval="00:20:00" flowControlEnabled="true"
                inactivityTimeout="00:59:00" maxPendingChannels="4" maxRetryCount="8"
                maxTransferWindowSize="8" ordered="true" reliableMessagingVersion="Default" />
              <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                messageVersion="Default" writeEncoding="utf-8">
                <readerQuotas maxDepth="64" maxStringContentLength="2147483647"
                  maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </textMessageEncoding>
              <httpTransport manualAddressing="false" maxBufferPoolSize="2147483647"
                maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Basic"
                bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
                keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
                realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                useDefaultWebProxy="true" />
            </binding>
          </customBinding>

    Endpoint behaviour (Client side):

        <behaviors>
          <endpointBehaviors>
            <behavior name="DesignBehaviour">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>
        </behaviors>

    The Binding (Server side):

          <customBinding>
            <binding name="ProjectDesignBinding" receiveTimeout="00:59:00" sendTimeout="00:59:00" openTimeout="00:59:00" closeTimeout="00:59:00">
              <textMessageEncoding>
                <readerQuotas maxDepth="64" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              </textMessageEncoding>
              <reliableSession acknowledgementInterval="00:20:00" inactivityTimeout="00:59:00" ordered="true" flowControlEnabled="false" />
              <httpTransport authenticationScheme="Basic" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" />
            </binding>
          </customBinding>

    Endpoint behaviour (Server side):

        <behaviors>
          <serviceBehaviors>
            <behavior name="Project.API.Design.ProjectDesign">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
              <serviceCredentials>
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Project.Account.WebServiceCustomValidator,Project"></userNameAuthentication>
              </serviceCredentials>
            </behavior>
          </serviceBehaviors>
        </behaviors>

    If I cannot find the exact cause, then I believe that I have the options below to follow on:
    - Chunking Channel (http://msdn.microsoft.com/en-us/library/aa717050.aspx).
    - Data compression.

    I will prefer to at least configure it to handle the maximum of data before moving into optimization and compression though.

    Regards,

    Nisha

    Tuesday, February 7, 2012 5:12 PM

Answers

  • Is it just on a single machine or the error comes when you are trying it on different machines as well. Also have you made sure to set the HttpRuntime property?

    <system.web>    
        <httpRuntime maxRequestLength="2147483647" />     
      </system.web>

    Also just cross check the following:

    1. See if the machine has enough physical memory available

    2. The number of requests being processed


    Rajesh S V

    • Marked as answer by Yi-Lun Luo Friday, February 17, 2012 2:27 AM
    Tuesday, February 14, 2012 11:05 AM

All replies

  • In you service and endpoint configuration do you configure the servicebahavior and endpointbehavior 

    <service name="xyz"  

    behaviorConfiguration="
    Project.API.Design.ProjectDesign
    "/>

    Similarly in endpoint configuration ... 

    Could you please enable tracing in your service ? It will point you to the exact error you are getting. Sometimes this high level error are bit misleading. 


    Tanvir Huda Application Architect/Consultant

    Wednesday, February 8, 2012 9:09 AM
  • Please enable Tracing on your service and inspect the Trace logs to get an exact idea on where the error is being thrown. 

    Rajesh S V

    Wednesday, February 8, 2012 9:56 AM
  • Tanvir Huda, 

    Thank you for your reply. Sorry for the late response, I assumed I would receive a notification. Yes, I did include the behaviorConfiguration attribute in the service/endpoint definition. 

    Yes, I know about those high level errors that does not help at all. This one was actually a low level one that I got when enabling wcf tracing.


    Monday, February 13, 2012 9:53 AM
  • Rajesh S V,

    Thank you for looking into this issue. Please see my reply to Tanvir Huda. 

    Monday, February 13, 2012 9:54 AM
  • Hi Nisha,

    Can you check to see if the support article is applicable in your case.

    http://support.microsoft.com/kb/974065


    Rajesh S V

    Monday, February 13, 2012 10:26 AM
  • Hi Rajesh,

    I've seen this page. Firstly, the computer do not have over 8 processors. However, I still read through it and from my understanding, the resolution section said to contact microsoft support.

    There is a workaround around section "http://msdn.microsoft.com/en-us/library/at1stbec.aspx" which did not make any difference when applied.

    Regards,

    Nisha

    Tuesday, February 14, 2012 10:18 AM
  • Is it just on a single machine or the error comes when you are trying it on different machines as well. Also have you made sure to set the HttpRuntime property?

    <system.web>    
        <httpRuntime maxRequestLength="2147483647" />     
      </system.web>

    Also just cross check the following:

    1. See if the machine has enough physical memory available

    2. The number of requests being processed


    Rajesh S V

    • Marked as answer by Yi-Lun Luo Friday, February 17, 2012 2:27 AM
    Tuesday, February 14, 2012 11:05 AM
  • For information, I do not believe this was the answer. I do not have access to that particular database and therefore could not reply with the exact facts.

    Two machines with 4gig and 8gig of RAM had this issue.

    At the time, I did set maxRequestLength="2147483647" which was needed for file upload (not related to this issue).

    For physical memory, I do not believe that this is the issue as one computer had 8 gig of RAM. But I cannot say how much was available at the time though.

    As for the number of requests, it is a simple web service call that retrieves records in the database, create a list of objects and return that list to the client to display as a table in the UI. 

    I will update this forum when I reproduce the error and found the solution.

    Tuesday, February 28, 2012 7:36 AM
  • I was getting the same exception.

    I decided to try host my service in IIS instead of WebDev.

    This fixed the issue.

    Hope this helps anyone.

    Friday, July 25, 2014 11:28 AM
  • I have a problem i am using the following configuration at production machine this configuration give me this error.

    "Failed to allocate a managed memory buffer of 67108864 bytes. The amount of available memory may be low."

    but when i restore same database on my development machine and run the service with same configuration it works fine.

    Binding Client Side

    <bindings>
          <wsHttpBinding>
            <binding name="ExtendedwsHttpBinding" maxReceivedMessageSize="2147483647" sendTimeout="23:59:59" textEncoding="utf-16">
              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"   />
              <security>
                <message establishSecurityContext="false"  />
              </security>
            </binding>
          </wsHttpBinding>
    </bindings>

    Binding Server Side:

    <bindings>
          <wsHttpBinding>
            <binding name="ExtendedConfiguration" maxReceivedMessageSize="2147483647">
              <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
              <security>
                <message establishSecurityContext="false" />
              </security>
            </binding>
        </bindings>

    behaviour server side:

    <behaviors>
          <serviceBehaviors>
            <behavior name="returnFaults">
              <serviceDebug includeExceptionDetailInFaults="true" />
              <serviceMetadata httpGetEnabled="true" />
              <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
    
        </behaviors>

    but on production server it gives the error

    The underlying connection was closed: The connection was closed unexpectedly."

    and when i run the trace for WCF service i found out

    "Failed to allocate a managed memory buffer of 67108864 bytes. The amount of available memory may be low."

    can any one tell me how can i solve this problem

    Regads,

    ADL

    Wednesday, August 6, 2014 11:54 AM