C++ / JNI memory leakage, help needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Asko Seeba

    #31
    Re: C++ / JNI memory leakage, help needed

    George Neuner wrote:[color=blue]
    > On 3 Apr 2004 23:50:20 -0800, andreas.toresat er@aetdata.com (Sambucus)
    > wrote:[color=green]
    >>However i had tried to use something like this:
    >>
    >>return env->NewStringUTF(o utput);
    >>
    >> }
    >> __finally
    >> {
    >> output= NULL;
    >> delete [] output;
    >> size=NULL;[/color]
    >
    > C++ itself doesn't have a "finally" keyword, but Microsoft compilers
    > support a "try-finally" construct as a language extension.[/color]
    [...]

    This is actually the first posting I am catching from this thread and
    sorry, if my posting is already hopelessly late, but what is the point
    of assigning NULL to output and then deleting the output (being NULL)?
    Shouldn't it be vice versa? For me, it seems like this is THE memory leak.

    --
    Asko Seeba

    Comment

    • George Neuner

      #32
      Re: C++ / JNI memory leakage, help needed

      On Wed, 05 May 2004 08:33:39 +0300, Asko Seeba
      <asko@spamm.is. forbidden.cyber .ee> wrote:
      [color=blue]
      >George Neuner wrote:[color=green]
      >> On 3 Apr 2004 23:50:20 -0800, andreas.toresat er@aetdata.com (Sambucus)
      >> wrote:[color=darkred]
      >>>However i had tried to use something like this:
      >>>
      >>>return env->NewStringUTF(o utput);
      >>>
      >>> }
      >>> __finally
      >>> {
      >>> output= NULL;
      >>> delete [] output;
      >>> size=NULL;[/color]
      >>
      >> C++ itself doesn't have a "finally" keyword, but Microsoft compilers
      >> support a "try-finally" construct as a language extension.[/color]
      >[...]
      >
      >This is actually the first posting I am catching from this thread and
      >sorry, if my posting is already hopelessly late, but what is the point
      >of assigning NULL to output and then deleting the output (being NULL)?
      >Shouldn't it be vice versa? For me, it seems like this is THE memory leak.[/color]

      Yup! ... hopelessly late 8-)

      The quoted code definitely leaks. The OP's is new to C++ and his
      original code simply forgot to free the string. That error was dealt
      with in the thread and the OP's latest inquiries concern C++ language
      and compiler issues.

      George
      =============== =============== ===============
      Send real email to GNEUNER2 at COMCAST o NET

      Comment

      Working...