locked
ASP.NET web api memory(RAM) problems RRS feed

  • Question

  • User-1846695518 posted

    Hello,

    I have a asp.net web api which devlivers very small amount of data but heavily used .

    My method is

      public HttpResponseMessage GetFingerprint(string id, string fingerprintVersion, string snapshotVersion, string thesaurus)
            {
                HttpResponseMessage badAccessResponse = CheckAccess(_serviceHelper, ExportCommon.Models.Request.Type.FingerprintDocument, null);
                if (badAccessResponse != null) return badAccessResponse;

                HttpResponseMessage response = Request.CreateResponse();

                FingerprintRequest fingerprintRequest = new FingerprintRequest();
                fingerprintRequest.id = id;
                fingerprintRequest.Resource = "Document";
                fingerprintRequest.FingerprintVersion = fingerprintVersion;
                fingerprintRequest.SnapshotVersion = snapshotVersion;
                fingerprintRequest.Thesaurus = thesaurus;

                var fingerprintStream = new FingerprintStream(fingerprintRequest);

                var mediaTypeHeaderValue = new MediaTypeHeaderValue("text/xml");
                mediaTypeHeaderValue.CharSet = "utf-8";

                response.Content = new StringContent(fingerprintStream.GetFingerprintsByDocId(), Encoding.UTF8, "text/xml");

                //response.Content = new PushStreamContent(fingerprintStream.WriteToStream, mediaTypeHeaderValue);
     

                return response;

            }

    But the memory is constantly increasing . So in application poll , I have  a setting to limit and recyle at 7GB. Some time this is causing 500 Internal Server error on client side.

    Can some one let me know what could the possibel reasons that memory is getting increased.

    How can we clean memory?.

    Regards,

    Ayyappa K

    Friday, December 12, 2014 7:54 AM

Answers

  • User690216013 posted

    It has nothing to do with ASP.NET Web API. What is your FingerprintStream? Freeing up such objects and you should be able to reduce memory footprint of this application.

    Please find a good enough memory profiler such as ANTS profiler, and then you can easily observe how the memory is used by the objects.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, December 12, 2014 10:30 PM

All replies

  • User690216013 posted

    It has nothing to do with ASP.NET Web API. What is your FingerprintStream? Freeing up such objects and you should be able to reduce memory footprint of this application.

    Please find a good enough memory profiler such as ANTS profiler, and then you can easily observe how the memory is used by the objects.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Friday, December 12, 2014 10:30 PM
  • User-1846695518 posted

    Thank you Lex,

    I will try using ANTS profiler .

    Monday, December 15, 2014 3:27 AM