You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by Guilhem Tardy <gr...@yahoo.com> on 2006/01/16 17:21:01 UTC

memory alloc/free across DLL boudaries

Hi,

I am copying part of my previous email into this new thread, because it seems a
problem shared by many (according to the mailing list archive) and IMHO quite
serious.

Deleting objects across DLL causes exception, in particular from the "simple"
(Calculator) sample:

xsd__int Calculator::div(xsd__int Value0, xsd__int Value1)
...
		xsd__int r = *Ret;
//		delete Ret;
		return r;
	}

Another service (ref) completely fails due apparently to the same problem, and
I am incapable to find an easy way to solve it.

Granted that eventually my goal is to get all the client SOAP functionality
into one static library, which may solve the above issue if there were any easy
way to do that.

Unfortunately, unlike Xerces (built DLL and static in matter of minutes), Axis
CPP shows no such easy way of making static libraries.

As a matter of fact, in several days of debugging the standard "DLL" build
system, I have come across several calls to openLib that mean usage of DLL is
hardcoded into Axis CPP.

I would love to hear anyone prove me wrong. Please?

Guilhem.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: memory alloc/free across DLL boudaries

Posted by Petr Cvachoucek <cv...@unicontrols.cz>.
Hi,
try to check what is your runtime library settings in all projects. In 
MSVC the settings can be found somewhere in the "Code generation" tab 
(project properties). You need the "Multi-threaded DLL" option 
(Multi-threaded Debug DLL for debug version) to be set for all projects 
(xerces dll, axis dlls, web services). Make sure you have the same 
settings for all projects. In general, you need all components to use 
the same instance of C runtime library, and its possible only with 
runtime linked as dll. If you link components statically, every 
component have its own copy of runtime library and this means it have 
its own heap and new/delete operators. The problem you hit is exactly 
this, an object was allocated from heap other than yours, so you cannot 
delete it from your heap.
Hope this helps
Petr

Guilhem Tardy wrote:
> Hi,
> 
> I am copying part of my previous email into this new thread, because it seems a
> problem shared by many (according to the mailing list archive) and IMHO quite
> serious.
> 
> Deleting objects across DLL causes exception, in particular from the "simple"
> (Calculator) sample:
> 
> xsd__int Calculator::div(xsd__int Value0, xsd__int Value1)
> ...
> 		xsd__int r = *Ret;
> //		delete Ret;
> 		return r;
> 	}
> 
> Another service (ref) completely fails due apparently to the same problem, and
> I am incapable to find an easy way to solve it.
> 
> Granted that eventually my goal is to get all the client SOAP functionality
> into one static library, which may solve the above issue if there were any easy
> way to do that.
> 
> Unfortunately, unlike Xerces (built DLL and static in matter of minutes), Axis
> CPP shows no such easy way of making static libraries.
> 
> As a matter of fact, in several days of debugging the standard "DLL" build
> system, I have come across several calls to openLib that mean usage of DLL is
> hardcoded into Axis CPP.
> 
> I would love to hear anyone prove me wrong. Please?
> 
> Guilhem.
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>