使用.NET Web服务(C ++)时Memoryleak [英] Memoryleak when using a .NET webservice (C++)

查看:68
本文介绍了使用.NET Web服务(C ++)时Memoryleak的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一名软件工程师,我的软件开发了一个插件系统。其中一个插件是一个soapserver,用于在我们的应用程序中执行一些操作。
插件是一个混合模式的DLL。全部用C ++编写

在插件中我使用此代码来设置服务:

I work as a software engineer and for our software I developed a plugin system. One of the plugins is a soapserver that is used to execute some things in our application.
The plugin is an mixed mode dll. All is written in C++

In the plugin I use this code to set up the service:

HttpChannel ^chan = gcnew HttpChannel(webServicePort);
ChannelServices::RegisterChannel(chan,false);
String ^webServiceNameString = gcnew String(webServiceName);
RemotingConfiguration::RegisterWellKnownServiceType (Type::GetType("OMOPI.ExecuteMacro"), webServiceNameString, WellKnownObjectMode::SingleCall);


OMOPI.ExecuteMacro头文件:

OMOPI.ExecuteMacro header file:

#include "plugininterface/omtls_iapplicationforplugin.h"
#include "soap/omopi_soapengine_clr.h"
#include "plugin/omopi_soapplugin.h"
#using <System.dll>

using namespace System;
using namespace System::Runtime::InteropServices;

namespace OMOPI
   {
   public ref class ExecuteMacro : public MarshalByRefObject
      {
      public:
         ExecuteMacro();
         ~ExecuteMacro();
            
         Object ^executeMacro(String ^macroName, array<Object^>^ args);

      private:
         OMTLS::IApplicationForPlugin  *m_application;
         SoapPlugin                    *m_plugin;
      };
   }


OMOPI.ExecuteMacro cpp文件(我排除了执行的实际代码,因为memoryleak不是由该代码引起的):

OMOPI.ExecuteMacro cpp file (I excluded the actual code that is executed because memoryleak is not caused by that code):

#pragma managed
#include "soap/omopi_executemacro_clr.h"

#include "plugininterface/omtls_iexpressions.h"

#include "plugin/omopi_macroaction.h"
#include "plugin/omopi_logfile.h"
#include <stdarg.h>

#using<System.Web.Services.dll>
#using<System.Xml.dll>

using namespace OMOPI;

ExecuteMacro::ExecuteMacro()
   {
   SoapEngine *engine = SoapEngine::getSoapEngine();
   m_application = engine->getApplicationInterface();
   m_plugin = (SoapPlugin *)(engine->getPlugin());
   }

ExecuteMacro::~ExecuteMacro()
   {
   }

Object ^ExecuteMacro::executeMacro(String ^macroName, array<Object^>^ args)
   {
   return NULL;
   }


当客户端请求executeMacro时,一切正常但我们注意到虚拟内存增加了64k。
当应用程序运行时有一段时间内存增加会导致崩溃,因为电脑没有虚拟存储器。

有没有人知道这个泄漏的原因以及我们问题的可能解决方案?

Thanx

When a client requests an executeMacro all works fine but we noticed an increase of 64k of the virtual memory.
When the application is run for a while the increasing of the memory causes a crash because the pc is out of virtual memory.

Has anyone an idea whats the cause of this leak and a possible solution for our problem?

Thanx

推荐答案

副手,我不知道你问题的答案。为了调试内存泄漏,我们需要收集一些数据。

你有没有看过崩溃时堆的形状?堆转储上有哪些对象?这些对象在哪里生根?

要收集堆转储,请尝试调试器,例如windbg。这很难学,但有时很有用。

Off hand, I do not know the answer to your question.  To debug memory leaks, we need to collect some data.

Have you taken a look at the shape of the heap when it crashed?  What kind of objects are on the heap dump?  Where are these objects rooted?

To collect the heap dump, try a debugger such as windbg.  It's hard to learn, but useful at times such as these.


这篇关于使用.NET Web服务(C ++)时Memoryleak的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆