×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    1

    User::Leave doesn't work as expected and can leak memory

    Take a look at following function:

    void leaksL(TInt arg) {
    Foo foo(1000);

    // do some thing here

    if (on_some_condition) {
    User::Leave(KSomeConstant);
    }

    // some code here;
    }

    Now if someone calls leaksL() method, and if it leaves, what I have noticed is the destructor for object "foo" doesn NOT get called.

    In C++ or Java when an exception is raised its is gauranteed that all the variables that are on the stack (local or auto variables) wil be cleaned up and their destructors be called.

    Symbian C++ claims that User::Leave behaves like C++ or Java exceptions. But in fact it doesnt work as expected.

    Any help or comments are welcome. I am sure this is pretty basic behaviour to expect. Is this a bug. I am using Series 60 SDK v1.2

    -Atul

  2. #2
    Registered User
    Join Date
    Apr 2005
    Location
    Barcelona
    Posts
    1,678

    Re: User::Leave doesn't work as expected and can leak memory

    That is correct. Symbian leaves and C++ exceptions are different beasts.
    However, note that you should stick to conventions. Check C, R, T, etc. classes, its constraints, and then see how it fits in your Foo class example.

    Regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •