Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

simple isapi extension : memory leak detected

 
   Web Hosting and Web Master Forums (Home) -> IIS RSS
Next:  Please help me..problem with session  
Author Message
Marty Sheffield

External


Since: Mar 25, 2005
Posts: 1



(Msg. 1) Posted: Fri Mar 25, 2005 12:01 pm
Post subject: simple isapi extension : memory leak detected
Archived from groups: microsoft>public>inetserver>iis (more info?)

I started by trying to figure out where a memory leak in my isapi
extension was coming from, so I built a super simple MFC isapi with the
wizard (using VS .net 2002). It only has 3 parse commands; default,
emptyTest, and variableTest. Both default & emptyTest take no
parameters, the latter takes one. Whenever I call the methods that do
not take variables, I dont see a leak. When i call the variable test
(/testIsapi.dll?variableTest&var=test), CRT detects leaks when the dll is
unloaded (there's always 4 reported leaks). I'm wondering what gives,
and what I can do to correct this, I've been googling all day.


<the error>
[2248] Detected memory leaks!
[2248] Dumping objects ->
[2248] {55}
[2248] normal block at 0x00A64090, 8 bytes long.
[2248] Data: < > CD CD CD CD CD CD CD CD
[2248] {54}
[2248] normal block at 0x00A64058, 8 bytes long.
[2248] Data: <(@ > 28 40 A6 00 00 00 00 00
[2248] {53}
[2248] normal block at 0x00A64028, 4 bytes long.
[2248] Data: <var > 76 61 72 00
[2248] {52}
[2248] normal block at 0x00A62958, 16 bytes long.
[2248] Data: < X@ @ > 01 00 00 00 01 00 00 00 58 40 A6 00 90
40 A6 00

<testIsapi.cpp>
// testIsapi.cpp - Implementation file for ISAPI
// testIsapi Extension

#include "stdafx.h"
#include "testIsapi.h"


// The one and only CWinApp object
// NOTE: You may remove this object if you alter your project to no
// longer use MFC in a DLL.

CWinApp theApp;


// command-parsing map

BEGIN_PARSE_MAP(CtestIsapiExtension, CHttpServer)
  // TODO: insert your ON_PARSE_COMMAND() and
  // ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
  // For example:

  ON_PARSE_COMMAND(Default, CtestIsapiExtension, ITS_EMPTY)

  ON_PARSE_COMMAND(emptyTest, CtestIsapiExtension, ITS_EMPTY)

ON_PARSE_COMMAND(variableTest, CtestIsapiExtension, ITS_PSTR)
ON_PARSE_COMMAND_PARAMS("var=~")

  DEFAULT_PARSE_COMMAND(Default, CtestIsapiExtension)
END_PARSE_MAP(CtestIsapiExtension)



// The one and only CtestIsapiExtension object

CtestIsapiExtension theExtension;



// CtestIsapiExtension implementation

CtestIsapiExtension::CtestIsapiExtension()
{
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
}

CtestIsapiExtension::~CtestIsapiExtension()
{
_CrtDumpMemoryLeaks();

}

BOOL CtestIsapiExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
{
  // Call default implementation for initialization
  CHttpServer::GetExtensionVersion(pVer);

  // Load description string
  TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
  ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
    IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
  _tcscpy(pVer->lpszExtensionDesc, sz);
  return TRUE;
}

BOOL CtestIsapiExtension::TerminateExtension(DWORD dwFlags)
{
  // extension is being terminated
  //TODO: Clean up any per-instance resources
  return TRUE;
}


// CtestIsapiExtension command handlers

void CtestIsapiExtension::Default(CHttpServerContext* pCtxt)
{
  StartContent(pCtxt);
  WriteTitle(pCtxt);

  *pCtxt << _T("This is the default message");

  EndContent(pCtxt);
}

// CtestIsapiExtension command handlers

void CtestIsapiExtension::emptyTest(CHttpServerContext* pCtxt)
{
  StartContent(pCtxt);
  WriteTitle(pCtxt);

  *pCtxt << _T("This is the emptyTest page<br>\r\n");

  EndContent(pCtxt);
}

// CtestIsapiExtension command handlers

void CtestIsapiExtension::variableTest(CHttpServerContext* pCtxt, LPTSTR
pszVar)
{
  StartContent(pCtxt);
  WriteTitle(pCtxt);

  *pCtxt << _T("This is the variableTest page<br>\r\n");
  *pCtxt << _T(pszVar);
*pCtxt << _T("<br>\r\n");

  EndContent(pCtxt);
}





// If your extension will not use MFC, you'll need this code to make
// sure the extension objects can find the resource handle for the
// module. If you convert your extension to not be dependent on MFC,
// remove the comments around the following AfxGetResourceHandle()
// and DllMain() functions, as well as the g_hInstance global.

/****

static HINSTANCE g_hInstance;

HINSTANCE AFXISAPI AfxGetResourceHandle()
{
  return g_hInstance;
}

BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
    LPVOID lpReserved)
{
  if (ulReason == DLL_PROCESS_ATTACH)
  {
   g_hInstance = hInst;
  }

  return TRUE;
}

****/



<testIsapi.h>
#pragma once


// testIsapi.h - Header file for your Internet Information Server
// testIsapi Extension

#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif

#include "resource.h"

class CtestIsapiExtension : public CHttpServer
{
public:
  CtestIsapiExtension();
  ~CtestIsapiExtension();

  // Overrides
public:
  virtual BOOL GetExtensionVersion(HSE_VERSION_INFO* pVer);
  virtual BOOL TerminateExtension(DWORD dwFlags);

  // TODO: Add handlers for your commands here.
  // For example:

  void Default(CHttpServerContext* pCtxt);
void emptyTest(CHttpServerContext* pCtxt);
void variableTest(CHttpServerContext* pCtxt, LPTSTR pszVar);

  DECLARE_PARSE_MAP()
};<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: simple isapi extension : memory leak detected 
Back to top
Login to vote
someone9

External


Since: Aug 25, 2003
Posts: 2419



(Msg. 2) Posted: Fri Mar 25, 2005 11:45 pm
Post subject: Re: simple isapi extension : memory leak detected [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Sorry, but you are using the MFC Framework, so any issues you have with it
will have to be brought up in the VC/MFC newsgroup.

Personally, I would use the pure ISAPI API. The MFC ISAPI gives you very
little but a lot of overhead in a "framework". Parameter parsing is pretty
trivial code to write a tight/fast implementation. And even right now, I
have no idea whether the framework has a leak, and if it does, is it 4
allocations per parameter or ??

--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
"Marty Sheffield" <someone.RemoveThis@online.com> wrote in message
news:Xns962498C6C7833martysheffieldnospam@207.46.248.16...
I started by trying to figure out where a memory leak in my isapi
extension was coming from, so I built a super simple MFC isapi with the
wizard (using VS .net 2002). It only has 3 parse commands; default,
emptyTest, and variableTest. Both default & emptyTest take no
parameters, the latter takes one. Whenever I call the methods that do
not take variables, I dont see a leak. When i call the variable test
(/testIsapi.dll?variableTest&var=test), CRT detects leaks when the dll is
unloaded (there's always 4 reported leaks). I'm wondering what gives,
and what I can do to correct this, I've been googling all day.


<the error>
[2248] Detected memory leaks!
[2248] Dumping objects ->
[2248] {55}
[2248] normal block at 0x00A64090, 8 bytes long.
[2248] Data: < > CD CD CD CD CD CD CD CD
[2248] {54}
[2248] normal block at 0x00A64058, 8 bytes long.
[2248] Data: <(@ > 28 40 A6 00 00 00 00 00
[2248] {53}
[2248] normal block at 0x00A64028, 4 bytes long.
[2248] Data: <var > 76 61 72 00
[2248] {52}
[2248] normal block at 0x00A62958, 16 bytes long.
[2248] Data: < X@ @ > 01 00 00 00 01 00 00 00 58 40 A6 00 90
40 A6 00

<testIsapi.cpp>
// testIsapi.cpp - Implementation file for ISAPI
// testIsapi Extension

#include "stdafx.h"
#include "testIsapi.h"


// The one and only CWinApp object
// NOTE: You may remove this object if you alter your project to no
// longer use MFC in a DLL.

CWinApp theApp;


// command-parsing map

BEGIN_PARSE_MAP(CtestIsapiExtension, CHttpServer)
// TODO: insert your ON_PARSE_COMMAND() and
// ON_PARSE_COMMAND_PARAMS() here to hook up your commands.
// For example:

ON_PARSE_COMMAND(Default, CtestIsapiExtension, ITS_EMPTY)

ON_PARSE_COMMAND(emptyTest, CtestIsapiExtension, ITS_EMPTY)

ON_PARSE_COMMAND(variableTest, CtestIsapiExtension, ITS_PSTR)
ON_PARSE_COMMAND_PARAMS("var=~")

DEFAULT_PARSE_COMMAND(Default, CtestIsapiExtension)
END_PARSE_MAP(CtestIsapiExtension)



// The one and only CtestIsapiExtension object

CtestIsapiExtension theExtension;



// CtestIsapiExtension implementation

CtestIsapiExtension::CtestIsapiExtension()
{
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
}

CtestIsapiExtension::~CtestIsapiExtension()
{
_CrtDumpMemoryLeaks();

}

BOOL CtestIsapiExtension::GetExtensionVersion(HSE_VERSION_INFO* pVer)
{
// Call default implementation for initialization
CHttpServer::GetExtensionVersion(pVer);

// Load description string
TCHAR sz[HSE_MAX_EXT_DLL_NAME_LEN+1];
ISAPIVERIFY(::LoadString(AfxGetResourceHandle(),
IDS_SERVER, sz, HSE_MAX_EXT_DLL_NAME_LEN));
_tcscpy(pVer->lpszExtensionDesc, sz);
return TRUE;
}

BOOL CtestIsapiExtension::TerminateExtension(DWORD dwFlags)
{
// extension is being terminated
//TODO: Clean up any per-instance resources
return TRUE;
}


// CtestIsapiExtension command handlers

void CtestIsapiExtension::Default(CHttpServerContext* pCtxt)
{
StartContent(pCtxt);
WriteTitle(pCtxt);

*pCtxt << _T("This is the default message");

EndContent(pCtxt);
}

// CtestIsapiExtension command handlers

void CtestIsapiExtension::emptyTest(CHttpServerContext* pCtxt)
{
StartContent(pCtxt);
WriteTitle(pCtxt);

*pCtxt << _T("This is the emptyTest page<br>\r\n");

EndContent(pCtxt);
}

// CtestIsapiExtension command handlers

void CtestIsapiExtension::variableTest(CHttpServerContext* pCtxt, LPTSTR
pszVar)
{
StartContent(pCtxt);
WriteTitle(pCtxt);

*pCtxt << _T("This is the variableTest page<br>\r\n");
*pCtxt << _T(pszVar);
*pCtxt << _T("<br>\r\n");

EndContent(pCtxt);
}





// If your extension will not use MFC, you'll need this code to make
// sure the extension objects can find the resource handle for the
// module. If you convert your extension to not be dependent on MFC,
// remove the comments around the following AfxGetResourceHandle()
// and DllMain() functions, as well as the g_hInstance global.

/****

static HINSTANCE g_hInstance;

HINSTANCE AFXISAPI AfxGetResourceHandle()
{
return g_hInstance;
}

BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason,
LPVOID lpReserved)
{
if (ulReason == DLL_PROCESS_ATTACH)
{
g_hInstance = hInst;
}

return TRUE;
}

****/



<testIsapi.h>
#pragma once


// testIsapi.h - Header file for your Internet Information Server
// testIsapi Extension

#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif

#include "resource.h"

class CtestIsapiExtension : public CHttpServer
{
public:
CtestIsapiExtension();
~CtestIsapiExtension();

// Overrides
public:
virtual BOOL GetExtensionVersion(HSE_VERSION_INFO* pVer);
virtual BOOL TerminateExtension(DWORD dwFlags);

// TODO: Add handlers for your commands here.
// For example:

void Default(CHttpServerContext* pCtxt);
void emptyTest(CHttpServerContext* pCtxt);
void variableTest(CHttpServerContext* pCtxt, LPTSTR pszVar);

DECLARE_PARSE_MAP()
};

 >> Stay informed about: simple isapi extension : memory leak detected 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
IIS 4.0 Memory Leak - Hi there, Im running in to major troubles on one of my production environments. Were running IIS4 on a NT machine and were getting a huge memory buildup in a short period of time. I'm talking about 1.4GB in less than 2 hours in the inetinfo process...

IIS Memory leak - We are currently trying to determine if we have a memory leak. I have searched and seen a number of posts about looking at Process\Private Bytes and Process\Virtual Bytes. What I have read indicates that if Private Bytes is increasing, you have a...

Memory Leak - Recently our IIS servers were rebuilt using better hardware. However, since the rebuilt we have been experiencing a memory leak problem and we have not been able to isolate the process causing it neither we have found major error in the ASP pages. Two...

Horrible memory leak - I've noticed dllhost.exe growing larger and larger. I looked at back posts and the response was a object collection problem in the coding. Well, to test this, I took a one line ".html" file and changed the extension to ".asp" Still...

Memory Leak and caching - Hello: I have an IIS 5.0 server (W2K sp2) server that has been locking up due to a memory leak. I know that IIS caches a lot of data and the TTL on the cache is 24 hours. To troubleshoot this I want to reduce the TTL to 12 hours and see if that help i...
   Web Hosting and Web Master Forums (Home) -> IIS All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]