AceTheInterview
Jobs in Pune | Work better in teams | Socialize with friends | Submit Q&A | Tell a friend
Search site for 

Top 100 Interview Questions & Answers in a convenient and easy to read book!

“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”

– Ravi, California

Read more comments...

Interview Questions And Answers RSS Feed

Answers »

  1. Submitted By: adi — November 29, 2006
    +8 votes
      + -

    ClenUp Stack

  2. Submitted By: Megha — September 24, 2007
    +1 votes
      + -

    To handle the exceptions in symbian we used the cleanup stack mechanism.The Symbian exception mechanism is based on leaving.The most important issue here is the Cleanup Stack.

    Symbian OS is optimized for low resource usage, and when an unexpected event occurs, there is a need to clean up all the currently allocated objects. To ensure you actually de-allocate ANY object you create, there is a stack, named the “Cleanup Stack”, where you push any object that needs to be de-allocated later. Consider this example:

    CDemo* demo = new CDemo;
    DangerousOperationL();
    delete demo;
    If the DangerousOperationL() leaves, the delete demo will never be reached, hence leaving the demo object allocated. The correct way is to use the cleanup stack as following:

    Ex.

    CDemo* demo = new CDemo();
    CleanupStack:: PushL(demo);
    DangerousOperationL();
    CleanupStack:: PopAndDestroy()

    When you create an object with new or NewL, you have to push it on the Cleanup Stack if any action that follows can leave. If you allocate an object with NewLC, it will be already pushed on the Cleanup Stack at the creation.

    After you are done with your object, you should destroy it. If the object is already on the Cleanup Stack, you should remove it from the stack with Pop then delete it. Or better, you can call PopAndDestroy to do both of them in a single step .

  3. Submitted By: Poonam — April 11, 2008
    not yet rated
      + -

    If a function leaves, control returns immediately to the trap harness within which it was called. This means that any automatic variables within functions called inside the trap harness are destroyed. A problem arises if any of these automatic variables are pointers to objects allocated on the heap: when the leave occurs and the pointer is destroyed, the object it pointed to is orphaned and a memory leak occurs.
    Example:
    TRAPD(error,doExampleL());

    void doExampleL()

    {

    CSomeObject* myObject1=new (ELeave) CSomeObject;

    CSomeObject* myObject2=new (ELeave) CSomeObject; // WRONG

    }

    In this example, if myObject1 was new’ed successfully, but there was insufficient memory to allocate myObject2, myObject1 would be orphaned on the heap. Thus, we need some mechanism for retaining any such pointers, so that the memory they point to can be freed after a leave. Symbian OS mechanism for this is the cleanup stack.

  4. Leave an Answer/Comment

    To prove you're a person (not a spam script), type the security text shown in the picture. Click here to regenerate some new text.
    Click to hear an audio file of the anti-spam word

Our Sponsors
Our Sponsors
Contact Us | FAQ | Sitemap | Terms of Use | Privacy Policy | Tell a Friend

Copyright © 1999-2006 Jeeve Technologies LLC. All rights reserved.