RE: Can this cause memory leak ?



No memory leak to worry about.

I will point out, it is inefficient and bad practice to catch exceptions
during the normal flow of your code. Adding a try/catch adds literally no
extra overhead but catching an exception is expensive, so your code should
only catch exceptions when an error is not normally expected.

Also, I always test for leaks (not just memory, handles, etc.) by opening
task manager and keeping an eye on mem usage, handles, threads, etc.

Mark.

"youhua.wang" wrote:

> We have a App ( WinCE x86 Application ), there are many try_catch handler
> like this:
>
> try
> {
> ...
> }
> catch (CException* pException)
> {
> ...
> pException->Delete();
> }
>
> And this work well. Now we transplant the App to WinCE ARM9 CPU platform,
> and the compiler complain that
> "catch (CException* pException) is not surport", so we replace it with
> catch(...), then the compiler go on.
>
> As a result, this time , we have exection handler like this:
>
> try
> {
> ...
> }
> //catch (CException* pException) //ARM9 CPU not surport this style
> catch( ... )
> {
> ...
> //pException->Delete(); // because no "pException" parameter
> }
>
> But I worry there is memory leak for lack the Delete() call.
> Is my worry unnecessary ?
>
> Any opnion are welcome!
>
> Thanks in Advance.
>
>
>
>
>
>
.



Relevant Pages

  • App issues with CE 5.0
    ... released and a memory leak results. ... creating but not destroying threads. ... that resulted in exceptions and these exceptions were traced to ATL. ... replaced the ATL SDK and atlce400.dll files with those from CE 4.0 and ...
    (microsoft.public.windowsce.platbuilder)
  • Re: SerialPort Class
    ... I've experienced sudden stops (no exceptions) due to a memory leak. ... method until a 'special character is received or a timeout elapses. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Allocatable Components of Derived Type
    ... One exception I guess is an allocatable array declared in a subroutine ... There are *NO* exceptions. ... Such a case will not cause a memory leak, ... If you try to allocate the array again without ...
    (comp.lang.fortran)
  • Dispose Unmanaged resources
    ... We all know that in .NET, we don't need to worry about memory leak ... illustrate the step necessary in disposing unmanaged resources. ... public static extern bool COMDbConnection (string connectionString, ...
    (microsoft.public.dotnet.general)
  • Re: Real life cost of using exceptions for control flow?
    ... I'm working with an app that uses exceptions for control flow. ... I would not worry about the cost of throwing/catching exception (although is ... because it is polluted by catch clauses that deal with the "normal" logic. ...
    (microsoft.public.dotnet.framework.performance)

Loading