Massive memory leak in WinCE Web Service ???

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Tim (tanisdaman[remove)
Date: 06/01/04


Date: Tue, 1 Jun 2004 08:01:06 -0700


Hello all! I am at my wits end and need a sanity check.

I am using WinCE.NET(4.2) on an x86 platform to host a very simple ASP web page that draws a Bitmap (the BMP comes from an EXE COM server). Everything seems to work great except the BinaryWrite method of the ‘Response’ object is leaking like a sieve.

Each time the web page is drawn ~120K(the size of the BMP) of memory will be leaked. If I comment out the call to BinaryWrite the memory leak goes away.

It looks like BinaryWrite is making its own copy of data, but never seems to free it.
Am I doing something wrong? Am I going crazy (quite a possibility)...

Any help will be much appreciated!
-Tim

The asp code:

<%
   Set oMyObject = CreateObject("MyServer.MyComObject.1")
   RawData = oMyObject.GetData
   Response.BinaryWrite RawData
%>

The C++ COM code:

STDMETHODIMP CMyComObject::GetData( /*[out,retval]*/ VARIANT* pVarVal)
{
    pVarVal->vt = VT_EMPTY;

    DWORD nHeight = 400;
    DWORD nWidth = 100;
    DWORD nArraySize = nHeight * nWidth * 3;

    SAFEARRAYBOUND bounds;
    bounds.lLbound = 0;
    bounds.cElements = nArraySize;
    
    SAFEARRAY* psa = SafeArrayCreate( VT_UI1, 1, &bounds );
    if( psa )
    {
        BYTE* pByteData;
        HRESULT hr = SafeArrayAccessData( psa, (void**)&pByteData );

        // put data into array
        
        hr = SafeArrayUnaccessData( psa );

        pVarVal->vt = VT_ARRAY | VT_UI1;
        pVarVal->parray = psa;
    }

    return S_OK;
}



Relevant Pages

  • Re: Massive memory leak in WinCE Web Service ???
    ... page that draws a Bitmap (the BMP comes from an EXE COM server). ... If I comment out the call to BinaryWrite the memory leak goes ... > Response.BinaryWrite RawData ...
    (microsoft.public.scripting.vbscript)
  • Re: Massive memory leak in WinCE Web Service ???
    ... page that draws a Bitmap (the BMP comes from an EXE COM server). ... If I comment out the call to BinaryWrite the memory leak goes ... > Response.BinaryWrite RawData ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Massive memory leak in WinCE Web Service ???
    ... page that draws a Bitmap (the BMP comes from an EXE COM server). ... If I comment out the call to BinaryWrite the memory leak goes ... > Response.BinaryWrite RawData ...
    (microsoft.public.inetserver.asp.general)
  • Massive memory leak in WinCE Web Service ???
    ... Each time the web page is drawn ~120K(the size of the BMP) of memory will be leaked. ... If I comment out the call to BinaryWrite the memory leak goes away. ... It looks like BinaryWrite is making its own copy of data, but never seems to free it. ... Response.BinaryWrite RawData ...
    (microsoft.public.scripting.vbscript)
  • Massive memory leak in WinCE Web Service ???
    ... Each time the web page is drawn ~120K(the size of the BMP) of memory will be leaked. ... If I comment out the call to BinaryWrite the memory leak goes away. ... It looks like BinaryWrite is making its own copy of data, but never seems to free it. ... Response.BinaryWrite RawData ...
    (microsoft.public.windowsce.platbuilder)