SlideShare a Scribd company logo
1 of 59
Symbian OS Memory Management v2.0a – 21 May 2008 1 Andreas Jakl, 2008
Disclaimer These slides are provided free of charge at http://www.symbianresources.com and are used during Symbian OS courses at the University of Applied Sciences in Hagenberg, Austria ( http://www.fh-hagenberg.at/ ) Respecting the copyright laws, you are allowed to use them: for your own, personal, non-commercial use in the academic environment In all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.at The correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not liable for incorrect information or damage that may arise from using the materials. Parts of these materials are based on information from Symbian Press-books published by John Wiley & Sons, Ltd. This document contains copyright materials which are proprietary to Symbian, UIQ, Nokia and SonyEricsson. “S60™” is a trademark of Nokia. “UIQ™” is a trademark of UIQ Technology. Pictures of mobile phones or applications are copyright their respective manufacturers / developers. “Symbian ™”, “Symbian OS ™” and all other Symbian-based marks and logos are trademarks of Symbian Software Limited and are used under license. © Symbian Software Limited 2006.  Andreas Jakl, 2008 2
Schedule Leaves, Panics and TRAP(D) Cleanupstack ObjectconstructionusingELeave Two-phaseconstruction Debugging tools Andreas Jakl, 2008 3
Leaves & Panics Handling problems Andreas Jakl, 2008 4
Exceptions – Java Try & Catch for handling exceptions Functions can throw “Exceptions” Andreas Jakl, 2008 5 Integer Class … static intparseIntthrowsNumberFormatException { … } … Calling function Try { int x = Integer.parseInt(“1234”); } catch (NumberFormatException e) { System.out.println(“Unable to convert this String to a number.”); }
Leave – Symbian TRAP(D) catches exceptions (“Leave”) Functions send out leave Function name marked by an L-suffix Andreas Jakl, 2008 6 The TRAP(D) macros are defined in e32cmn.h Main-Function TRAPD(err, DoExampleL());if (err)    {    console->Printf(KTxtFailed, err);    } DoExampleL()-Function voidDoExampleL()    {RFsfsSession;  // Connect to the file serverUser::LeaveIfError(fsSession.Connect()); // …fsSession.Close();    } TRAPD-Makro declares err as TInt and = KErrNone Leaves if the Connect() function does not return KErrNone
Central ExceptionHandling Andreas Jakl, 2008 7 New (ELeave) …  … NewL() …     … User::Leave() … … ConstructL() … F6L() F7L() F8L() F9L() F5L() F5L() …  … F6L() …. … F8L() …. F3L() F4L() F0L() F2L() … F3L() … F4L() … F1L() TRAPD(err, F2L()); if(err) …
Handling Leaves Try to implement central leave-handling If leave not handled by your code  error-message shown by the UI-framework! Therefore: Only handle leaves yourself if they influence your application Andreas Jakl, 2008 8
When can a function leave? Caused by your own code: User::Leave(), User::LeaveIfError(), User::LeaveNoMemory() or User::LeaveIfNull() Failed object-construction when using the “new (ELeave)”-operator Calling a function that potentially causes a leave e.g. x->DoSomethingL() Andreas Jakl, 2008 9
Details: Causing a Leave User::Leave(TIntaReason) Error code (aReason) = value that will be received by TRAP Causes leave in any case User::LeaveIfError(TIntaReason) Causes leave if parameter is negative, e.g.:TIntfoundAt = iElementArray.Find(example, aRelation);User::LeaveIfError(foundAt);	// Leaves if foundAt == KErrNotFound (-1) User::LeaveNoMemory() Is the same as: User:Leave(KErrNoMem); User::LeaveIfNull(TAny* aPtr) Andreas Jakl, 2008 10
TRAP / TRAPD Two trap harness macros: TRAP: declares the variable in which the leave code is returned TRAPD: declare a TIntvariable yourself If a leave occurs inside MayLeaveL(), which is executed inside the harness, the program code will return immediately to the TRAP harness macro The variable result will contain the error code associated with the leave or will be KErrNoneif no leave occured Andreas Jakl, 2008 11 TRAPD(result, MayLeaveL()); if (KErrNone!=result) ... is equivalent to: TIntresult; TRAP(result, MayLeaveL()); if (KErrNone!=result) ...
Tips Andreas Jakl, 2008 12 X voidInsertData()     { TInt err;     TRAP(err, iData->InsertL(23)); if (err) { ... }     TRAP(err, iData->InsertL(24)); if (err) { ... }     } TRAPs are expensive Don’t use several TRAPs right after each other Instead: Make the function leave (append an L to the function name) Handle all errors in a single TRAP-call one level above! In UI apps, many leaves don’t have to be handled by you  they can go up to the topmost level (= Active Scheduler) prefer  voidHandleCommand()     {     TRAPD(err, InsertDataL()); if (err) { ... }     } voidInsertDataL()     { iData->InsertL(23)); iData->InsertL(24));     }
Panics ... cannot be caught and handled! Terminates thread (= usually the whole application) Use them for checking code logic only Can also be sent out by the system for critical errors If a panic happens: Make sure you fix it, as you can’t handle it! Andreas Jakl, 2008 13 // Stray signal detected! _LIT(KMsgStraySignal, "Stray signal"); User::Panic(KMsgStraySignal, 1);		// Panic with code 1
Resource Handling Stack, Heap and the Cleanup Stack Andreas Jakl, 2008 14
Practice in a Nutshell All strategiesarepresent in thisfunction: Andreas Jakl, 2008 15 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }
Recap: Stack Andreas Jakl, 2008 16 // Stack (1) voidCTest::F1() { TInt x = 0; TInt y = 1; for(x = 0; x < 10; x++) 		y++ 	y = y + F2();  // Stack (4) } // Stack (5) TIntCTest::F2() { TInt a = 2; TInt b = 1; return a + b;   // Stack (3) } Stack (2) Stack (5) Stack (1) TInt y TInt x F1 Stack (2) TInt y TInt x F1 Stack (4) TInt b TInt a F2 TInt y TInt x F1 Stack (3)
Recap: Heap Use for: Objects that need a lot of memory ( stack-size is limited!) Required amount of memoryonlyknown at runtime Scope of heap-objects is not limited to a function Use pointers to pass to other functions/objects Andreas Jakl, 2008 17
Motivation Symbian OS designed to run for many years  No opportunity to reclaim leaked memory through regular restarts! Small memory leaks accumulate over time We only have a small memory to start with Therefore: Simply write perfect, leak-free code! Andreas Jakl, 2008 18
Motivation – How? By keeping track of all allocated objects! By making sure: All heap-objects are pointed to by at least one pointer, all the time – even in the constructor of an object! Free heap memory as soon as possible after use. Andreas Jakl, 2008 19
The Cleanup Stack Safeguard Andreas Jakl, 2008 20
Resource Handling – Rule 1 Andreas Jakl, 2008 21 Every local pointer to an instance of a heap-based object also has to be pushed on the cleanup stack, if there‘s the risk that the pointer gets lost because of a leave.
Cleanup Stack Situation: function creates local heap-object Before code gets to the delete-statement: error Function is left (Leave) Pointer-address on the stack is freed Object itself is orphaned memory leak! Andreas Jakl, 2008 22 voidCImage::DoSomethingDangerousL()     {     User::Leave(KErrNotFound);     } CImage voidCMyObj::DoSomethingL() { } CImage* img = new (ELeave) CImage(); img->DoSomethingDangerousL(); deleteimg; img = pointer on the stack to an instance on the heap
Cleanup Stack Memory situation if a leave occurs: Andreas Jakl, 2008 23 ! X X img Heap Stack Object stays on the heap;Pointer to delete the instance is lostmemory leak
Cleanup Stack Solution: Cleanup Stack Andreas Jakl, 2008 24 void CMyObj::DoSomethingL() { CImage* img = new (ELeave) CImage(); CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); } img  CleanupStack X X img Heap Stack When no leave occurs: object still has to be deleted by you + removed from the cleanup stack! Cleanup stack saves a second pointerto the object on the heap.
AdvancedCleanup Andreas Jakl, 2008 25 RFile Forresourcesthathavetobeclosed / freed(e.g.: files, sockets, …) Close(): CleanupClosePushL(T&) Release(): CleanupReleasePushL(T&) Destructor: CleanupDeletePushL(T*) Close() TCleanupOperation TAny* aPtr … TCleanupItem CleanupStack
AdvancedCleanup – Example Andreas Jakl, 2008 26 voidCMyClass::TransferDataL()     { RSocketServsocketServer;     // Connect to SocketServer     User::LeaveIfError( socketServer.Connect() );     // Make sure Close() is called at the end CleanupClosePushL( socketServer ); // … CleanupStack::PopAndDestroy();  //  socketServer     }
Cleanup Stack and Ownership Transfer It should never be possible for an object to be deleted more than once! Andreas Jakl, 2008 27 voidTransferOwnershipExampleL()     {     // The stack variable ptr points to memory allocated on the heap CItem* ptr = new (ELeave) CItem();     // The following function may leave -> place the pointer on the     // cleanup stack, so that the heap memory is freed in case      // AppendL() leaves. CleanupStack::PushL(ptr);     // iItemPtrArray takes ownership of the CItem object.     // This could fail, as it needs to allocate a new slot to store the pointer,      // therefore the object was placed on the cleanup stack in advance iItemPtrArray->AppendL(ptr);     // iItemArray now owns the heap object, so ptr may be safely popped off the stack.     // It shouldn’t be destroyed, as this would make the item in iItemPtrArray invalid! CleanupStack::Pop(ptr);     }
Practice in a Nutshell Strategiesexplaineduptonow: Andreas Jakl, 2008 28 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }  
Resource Handling – Rule 2 Andreas Jakl, 2008 29 Never push instance variables on the cleanup stack! The owning class is also on the cleanup stack somewhere (at least indirectly). This would lead to a double deletion of the object pointed to by the instance variable  Panic!
Coding Error Example Andreas Jakl, 2008 30 class CSimple : CBase     {        public:     ~CSimple();     void MayLeaveFuncL(); private:     void PrivateMayLeaveL(); CItem* iItem;     }; CSimple* simple = new (ELeave) CSimple(); CleanupStack::PushL(simple); 1. CSimple is created and pushed onto the cleanup stack as the next function may leave TRAPD(res,simple->MayLeaveFuncL()); ... 2. A leaving method is called on simple void CSimple::MayLeaveFuncL()     { iItem= new (ELeave) CItem(); CleanupStack::PushL(iItem); PrivateMayLeaveL(); CleanupStack::Pop(iItem);     } 3. The member variable is pushed onto the clean up stack (oops!) 5. The TRAP does the right thing and clears the cleanup stack; i.e. CSimple::iItem is deleted  4. What happens if a leaves occurs?  ... 6. The code logic completes with the popping and deleting of the simple object. CleanupStack::PopAndDestroy(simple); CSimple::~CSimple     {     delete iItem;     } BUT this calls the CSimple destructor, which deletes the iItem which has already been deleted by the TRAP   7. PANIC! Example taken from theSymbian Academy slides
Object Construction Leave-handling during Andreas Jakl, 2008 31
New Objects new-operator allocates memory and runs constructor Returns null-pointer if object creation fails(e.g. not enough memory)  manual test required to see if it was successful – no automated leave! Andreas Jakl, 2008 32 void CMyObj::DoSomethingL()     { CImage* img = newCImage();     if (img)          { CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); }      else         {         User::LeaveNoMemory();         }     }
New Objects – ELeave Andreas Jakl, 2008 33 void CMyObj::DoSomethingL()     { CImage* img = newCImage();     if (img)          { CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); }      else         {         User::LeaveNoMemory();         }     } void CMyObj::DoSomethingL()     { CImage* img = new (ELeave)CImage(); CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy();     } identical new-Operator overloaded with ELeave: automated leave if there’s not enough memory!
Practice in a Nutshell Strategiesexplained so far: Andreas Jakl, 2008 34 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }   
Two-Phase Construction The ultimate combination … Andreas Jakl, 2008 35
Resource Handling – Rule 3 Andreas Jakl, 2008 36 Neither a constructor nor a destructor may cause a leave! The destructor must not assume that the object was fully initialized.
Leaves in the Constructor Andreas Jakl, 2008 37 1. Call to constructorof CEngine Application CEngine* myEngine = new (ELeave) CEngine(); … … CEngine CEngine::CEngine() { iList = new (ELeave) CList(); } CEngine::~CEngine() { deleteiList; } iList CEngine 2. Leave – nomemory left for allocating iList Heap 3. Because of the leavethere is no valid pointerto the partially constructedCEngine-object. 4. Without a validpointer, the memoryalready allocatedfor CEngine is lost. ?
Solution: Two-phase Construction Andreas Jakl, 2008 38  Application CEngine* myEngine = new (ELeave) CEngine();CleanupStack::Push(myEngine); myEngine->ConstructL(); … // Note that the following line won’t be // reached in case of a leave!CleanupStack::PopAndDestroy(myEngine); CEngine CEngine::CEngine() {// 1. Phase } CEngine::ConstructL() {// 2. Phase iList = new (ELeave) CList(); } CEngine::~CEngine() { deleteiList; } iList CEngine Heap Object is fully allocated and on the cleanup stack  the destructor can be executed, the class is deleted by the cleanup stack  all memory is properly cleaned up in case of a leave!
Simplification: Two-phase Construction Less complicated creation of objects: Trailing C at the end of the function name: an object is left on the cleanup stack (as in NewLC()) Andreas Jakl, 2008 39 CEngine CEngine* CEngine::NewLC() {CEngine* self = new (ELeave) CEngine();    	// 1. PhaseCleanupStack::PushL(self);     self->ConstructL();    					// 2. Phase return self; } CEngine* CEngine::NewL() { CEngine* self = CEngine::NewLC(); CleanupStack::Pop(self); return self; } Application – Local Variable CEngine* myEngine = CEngine::NewLC(); … CleanupStack::PopAndDestroy(myEngine); or Application– Instance Variable iMyEngine = CEngine::NewL(); Destructor: delete iMyEngine; Application – Instance variable iMyEngine = CEngine::NewL(); // Destructor: deleteiMyEngine;
Practice in a Nutshell Strategiesexplained so far: Andreas Jakl, 2008 40  CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }     
Derivation Note: Some thoughts are necessary when deriving from a class that uses two-phase construction See the literature or Symbian Academy-slides for details! Andreas Jakl, 2008 41
Resource Handling – Rule 4 Andreas Jakl, 2008 42 If memory for a pointer (instance variable) is reallocated, set the old pointer to NULL beforehand.
NULL Situation (without NULL): AllocL() causes a leave, which propagates up … Instance of CElement is deleted Destructor of CElement is called iName still points to already deleted memory Deleted 2x           Panic Andreas Jakl, 2008 43 voidCEngine::DoStuffL(constTDesC& aName)     { CElement* element = CElement::NewLC();     TRAPD(err, element->SetNameL(aName)); CleanupStack::PopAndDestroy(element);         } 2 1 voidCElement::SetNameL(constTDesC& aName)     { deleteiName;	       // Deletes object, does not change pointer iName = aName.AllocL();	// Re-Allocation     } voidCElement::~CElement()     { deleteiName;     } 1 2 iName = NULL;       // Deletes pointer on stack Note: delete does not delete a NULL pointer.
Summary Andreas Jakl, 2008 44
Summary Catch leaves (= exceptions) with TRAP(D) Use cleanup stack for local heap-based variables Do not use the cleanup stack for instance variables No leaves in constructors or destructors Use two-phase construction for objects with data on the heap Set a pointer to NULL before re-allocating memory Andreas Jakl, 2008 45 !
What’s wrong? Andreas Jakl, 2008 46 CleanupStack::PushL(iList);
What’s wrong? Andreas Jakl, 2008 47 CleanupStack::PushL(iList); Never push instance variables on the cleanup stack! Twice as safe isn’t safe at all…
What’s wrong? Andreas Jakl, 2008 48 CEngine* engine = new (ELeave) CEngine();…CleanupStack::PopAndDestroy(engine)
What’s wrong? Andreas Jakl, 2008 49 CEngine* engine = new (ELeave) CEngine();…CleanupStack::PopAndDestroy(engine) enginewasn‘t pushed on the cleanup stack!new (ELeave) is only responsible for leaving if memory allocation for the object fails. new (ELeave) has nothing to do with the cleanup stack. Solution: Either: add the object to the cleanup stack: CleanupStack::PushL(engine); Or: don’t use the cleanup stack for deleting – in case no leaving operation is called between creation and deletion of the engine object: delete engine;
What’s wrong? Andreas Jakl, 2008 50 voidCGomokuViewGame::ChangeViewContextText(TIntaResourceId) 	{ RBufnewText(iEikonEnv->AllocReadResourceL(resourceId)); newText.CleanupClosePushL (); MQikViewContext* viewContext = ViewContext (); 	// Changing an alreadyexistingviewcontexttext viewContext->ChangeTextL (EGomokuViewContext, newText); CleanupStack::PopAndDestroy (1);	// newText 	}
What’s wrong? Andreas Jakl, 2008 51 void CGomokuViewGame::ChangeViewContextText(TInt aResourceId) 	{ 	RBuf newText(iEikonEnv->AllocReadResourceL(resourceId)); 	newText.CleanupClosePushL (); 	MQikViewContext* viewContext = ViewContext (); 	// Changing an already existing view context text 	viewContext->ChangeTextL (EGomokuViewContext, newText); 	CleanupStack::PopAndDestroy (1);	// newText 	} The trailing L of the function name is missing, as calls within the function can leave. Solution:void CGomokuViewGame::ChangeViewContextTextL(…)
Testing your Code On your way to perfection Andreas Jakl, 2008 52
Macros for Testing Wrap code you want to test within __UHEAP_MARK and __UHEAP_MARKEND: Andreas Jakl, 2008 53 CClass* p1 = new (ELeave) CClass; __UHEAP_MARK;// Mark start of test-area CClass* p2 = new (ELeave) CClass; CClass* p3 = new (ELeave) CClass; __UHEAP_CHECK(2);// 2 Objects (p2, p3) on the heap since the start-mark __UHEAP_CHECKALL(3);// In total 3 objects on the heap delete p3; _UHEAP_MARKEND;// Result: p2 is still here – Memory Leak! // or:  __UHEAP_MARKENDC(1);// Expects one cell on the heap
Finding Memory Leaks Emulator checksheapautomaticallyifyouexittheprogram BEFORE closingtheemulatorwindow! Andreas Jakl, 2008 54 Find it in theSymbian OS SDK doc: Symbian OS SDK v…  Symbian OS guide  Symbian OS reference  System panicreference
Memory Information Show numberofallocatedcells: Ctrl+Alt+Shift+A Andreas Jakl, 2008 55
Allocation Failure Intentional failing of memory allocation: __UHEAP_SETFAIL(aType, aValue); EDeterministic: fail every nth request ERandom: fail randomly once within a specified range – always using the same seed ETrueRandom: random seed taken from system time Andreas Jakl, 2008 56 __UHEAP_SETFAIL(RHeap::EDeterministic, 2); CObj* c1 = new (ELeave) CObj;		// will allocate CObj* c2 = new (ELeave) CObj;		// will fail CObj* c3 = new (ELeave) CObj;		// will allocate CObj* c4 = new (ELeave) CObj;		// will fail __UHEAP_RESET;	// Deactivate
FAILNEXT Fails thenextallocationrequest Andreas Jakl, 2008 57 CObj* c1 = new (ELeave) CObj;		// will allocate __UHEAP_FAILNEXT(1);// failnextallocation CObj* c2 = new (ELeave) CObj;		// will fail
AllocationFailure In theemulator, withoutwritingcode: Heap Failure Tool Activate:Ctrl+Alt+Shift+P Deactivate:Ctrl+Alt+Shift+Q Can failheap, WindowServer-allocationsorfile-access Andreas Jakl, 2008 58
… let’s move to the Challenges! Try it for your own Andreas Jakl, 2008 59

More Related Content

What's hot

Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureArvids Godjuks
 
MOBILE OPERATING SYSTEM
MOBILE OPERATING SYSTEMMOBILE OPERATING SYSTEM
MOBILE OPERATING SYSTEMcool192
 
Mobile Testing Service Desk_Own.ppt
Mobile Testing Service Desk_Own.pptMobile Testing Service Desk_Own.ppt
Mobile Testing Service Desk_Own.pptQA Programmer
 
Igor Nicoli: External scripts O poder do Zabbix em suas mãos
Igor Nicoli: External scripts O poder do Zabbix em suas mãosIgor Nicoli: External scripts O poder do Zabbix em suas mãos
Igor Nicoli: External scripts O poder do Zabbix em suas mãosZabbix BR
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 
Delivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devicesDelivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devicesAjeet Singh Raina
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageAnıl Sözeri
 
SDN and NFV: Friends or Enemies
SDN and NFV: Friends or EnemiesSDN and NFV: Friends or Enemies
SDN and NFV: Friends or EnemiesJustyna Bak
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6Gary Bisson
 
Perfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix Solutions
 
Kvm virtualization platform
Kvm virtualization platformKvm virtualization platform
Kvm virtualization platformAhmad Hafeezi
 
Introducing github.com/open-cluster-management – How to deliver apps across c...
Introducing github.com/open-cluster-management – How to deliver apps across c...Introducing github.com/open-cluster-management – How to deliver apps across c...
Introducing github.com/open-cluster-management – How to deliver apps across c...Michael Elder
 
Symbian OS Overview
Symbian OS OverviewSymbian OS Overview
Symbian OS OverviewAndreas Jakl
 
Palo Alto Networks 28.5.2013
Palo Alto Networks 28.5.2013Palo Alto Networks 28.5.2013
Palo Alto Networks 28.5.2013Belsoft
 
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...Docker, Inc.
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 

What's hot (20)

Zabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructureZabbix - an important part of your IT infrastructure
Zabbix - an important part of your IT infrastructure
 
MOBILE OPERATING SYSTEM
MOBILE OPERATING SYSTEMMOBILE OPERATING SYSTEM
MOBILE OPERATING SYSTEM
 
Mobile Testing Service Desk_Own.ppt
Mobile Testing Service Desk_Own.pptMobile Testing Service Desk_Own.ppt
Mobile Testing Service Desk_Own.ppt
 
Igor Nicoli: External scripts O poder do Zabbix em suas mãos
Igor Nicoli: External scripts O poder do Zabbix em suas mãosIgor Nicoli: External scripts O poder do Zabbix em suas mãos
Igor Nicoli: External scripts O poder do Zabbix em suas mãos
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Introduction to flutter
Introduction to flutter Introduction to flutter
Introduction to flutter
 
Delivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devicesDelivering Docker & K3s worloads to IoT Edge devices
Delivering Docker & K3s worloads to IoT Edge devices
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Samba
SambaSamba
Samba
 
SDN and NFV: Friends or Enemies
SDN and NFV: Friends or EnemiesSDN and NFV: Friends or Enemies
SDN and NFV: Friends or Enemies
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6
 
Perfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding StandardsPerfomatix - NodeJS Coding Standards
Perfomatix - NodeJS Coding Standards
 
Kvm virtualization platform
Kvm virtualization platformKvm virtualization platform
Kvm virtualization platform
 
Introducing github.com/open-cluster-management – How to deliver apps across c...
Introducing github.com/open-cluster-management – How to deliver apps across c...Introducing github.com/open-cluster-management – How to deliver apps across c...
Introducing github.com/open-cluster-management – How to deliver apps across c...
 
Symbian OS Overview
Symbian OS OverviewSymbian OS Overview
Symbian OS Overview
 
Linux Containers (LXC)
Linux Containers (LXC)Linux Containers (LXC)
Linux Containers (LXC)
 
Palo Alto Networks 28.5.2013
Palo Alto Networks 28.5.2013Palo Alto Networks 28.5.2013
Palo Alto Networks 28.5.2013
 
Kali Linux Installation - VMware
Kali Linux Installation - VMwareKali Linux Installation - VMware
Kali Linux Installation - VMware
 
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
Windows Server and Docker - The Internals Behind Bringing Docker and Containe...
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 

Viewers also liked

Symbian mobile operating system ppt
Symbian mobile operating system pptSymbian mobile operating system ppt
Symbian mobile operating system pptDevesh Singh
 
Symbian Operating system
Symbian Operating systemSymbian Operating system
Symbian Operating systemPravin Shinde
 
Symbian Os Introduction
Symbian Os IntroductionSymbian Os Introduction
Symbian Os IntroductionDeepak Rathi
 
Symbionic os
Symbionic osSymbionic os
Symbionic osbhavithd
 
Communication in Symbian OS
Communication in Symbian OSCommunication in Symbian OS
Communication in Symbian OSquasar_knowledge
 
Symbian OS - Communication And Messaging
Symbian OS - Communication And MessagingSymbian OS - Communication And Messaging
Symbian OS - Communication And MessagingAndreas Jakl
 
Chrome OS Observation
Chrome OS ObservationChrome OS Observation
Chrome OS ObservationChamp Yen
 
Google chrome os
Google chrome osGoogle chrome os
Google chrome osdevaj kumar
 
Chrome OS: The Stateless Operating System
Chrome OS: The Stateless Operating SystemChrome OS: The Stateless Operating System
Chrome OS: The Stateless Operating SystemChatchai Wangwiwattana
 
Google chrome os
Google chrome osGoogle chrome os
Google chrome osakoyena
 
Symbian OS - GUI Architectures
Symbian OS - GUI ArchitecturesSymbian OS - GUI Architectures
Symbian OS - GUI ArchitecturesAndreas Jakl
 

Viewers also liked (20)

Symbian OS
Symbian OSSymbian OS
Symbian OS
 
Symbian mobile operating system ppt
Symbian mobile operating system pptSymbian mobile operating system ppt
Symbian mobile operating system ppt
 
Symbian os presentation
Symbian os presentationSymbian os presentation
Symbian os presentation
 
Symbian Operating system
Symbian Operating systemSymbian Operating system
Symbian Operating system
 
Symbian Os Introduction
Symbian Os IntroductionSymbian Os Introduction
Symbian Os Introduction
 
Symbian OS
Symbian  OS Symbian  OS
Symbian OS
 
Symbian OS
Symbian OSSymbian OS
Symbian OS
 
Part 2
Part 2Part 2
Part 2
 
Symbionic os
Symbionic osSymbionic os
Symbionic os
 
Communication in Symbian OS
Communication in Symbian OSCommunication in Symbian OS
Communication in Symbian OS
 
Symbian OS - Communication And Messaging
Symbian OS - Communication And MessagingSymbian OS - Communication And Messaging
Symbian OS - Communication And Messaging
 
Chrome OS Observation
Chrome OS ObservationChrome OS Observation
Chrome OS Observation
 
Google chrome os
Google chrome osGoogle chrome os
Google chrome os
 
Chrome OS: The Stateless Operating System
Chrome OS: The Stateless Operating SystemChrome OS: The Stateless Operating System
Chrome OS: The Stateless Operating System
 
Google chrome os
Google chrome osGoogle chrome os
Google chrome os
 
Google chrome
Google chromeGoogle chrome
Google chrome
 
Google Chrome OS
Google Chrome OSGoogle Chrome OS
Google Chrome OS
 
Chrome os
Chrome os Chrome os
Chrome os
 
Symbian OS - GUI Architectures
Symbian OS - GUI ArchitecturesSymbian OS - GUI Architectures
Symbian OS - GUI Architectures
 
Google chrome OS
Google chrome OSGoogle chrome OS
Google chrome OS
 

Similar to Symbian OS - Memory Management

Symbian OS - Active Objects
Symbian OS - Active ObjectsSymbian OS - Active Objects
Symbian OS - Active ObjectsAndreas Jakl
 
Symbian OS - Dynamic Arrays
Symbian OS - Dynamic ArraysSymbian OS - Dynamic Arrays
Symbian OS - Dynamic ArraysAndreas Jakl
 
Symbian OS - Types And Declarations
Symbian OS - Types And DeclarationsSymbian OS - Types And Declarations
Symbian OS - Types And DeclarationsAndreas Jakl
 
Handling Exceptions In C & C++ [Part B] Ver 2
Handling Exceptions In C & C++ [Part B] Ver 2Handling Exceptions In C & C++ [Part B] Ver 2
Handling Exceptions In C & C++ [Part B] Ver 2ppd1961
 
Symbian OS - Descriptors
Symbian OS - DescriptorsSymbian OS - Descriptors
Symbian OS - DescriptorsAndreas Jakl
 
Java ME - 04 - Timer, Tasks and Threads
Java ME - 04 - Timer, Tasks and ThreadsJava ME - 04 - Timer, Tasks and Threads
Java ME - 04 - Timer, Tasks and ThreadsAndreas Jakl
 
Java ME - 06 - Record Stores, Distribution and Localization
Java ME - 06 - Record Stores, Distribution and LocalizationJava ME - 06 - Record Stores, Distribution and Localization
Java ME - 06 - Record Stores, Distribution and LocalizationAndreas Jakl
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded ProgrammingSri Prasanna
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Vincenzo Iozzo
 
Symbian OS - Quick Start
Symbian OS - Quick StartSymbian OS - Quick Start
Symbian OS - Quick StartAndreas Jakl
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templatesfarhan amjad
 
Java ME - 03 - Low Level Graphics E
Java ME - 03 - Low Level Graphics EJava ME - 03 - Low Level Graphics E
Java ME - 03 - Low Level Graphics EAndreas Jakl
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Hermann Hueck
 
Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6While42
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharingJames Hsieh
 
Using Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: BasicsUsing Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: BasicsEd Seidewitz
 
Rust and Eclipse
Rust and EclipseRust and Eclipse
Rust and EclipseMax Bureck
 

Similar to Symbian OS - Memory Management (20)

Symbian OS - Active Objects
Symbian OS - Active ObjectsSymbian OS - Active Objects
Symbian OS - Active Objects
 
Symbian OS - Dynamic Arrays
Symbian OS - Dynamic ArraysSymbian OS - Dynamic Arrays
Symbian OS - Dynamic Arrays
 
Symbian OS - Types And Declarations
Symbian OS - Types And DeclarationsSymbian OS - Types And Declarations
Symbian OS - Types And Declarations
 
Handling Exceptions In C & C++ [Part B] Ver 2
Handling Exceptions In C & C++ [Part B] Ver 2Handling Exceptions In C & C++ [Part B] Ver 2
Handling Exceptions In C & C++ [Part B] Ver 2
 
Symbian OS - Descriptors
Symbian OS - DescriptorsSymbian OS - Descriptors
Symbian OS - Descriptors
 
Computer Networks Omnet
Computer Networks OmnetComputer Networks Omnet
Computer Networks Omnet
 
Java ME - 04 - Timer, Tasks and Threads
Java ME - 04 - Timer, Tasks and ThreadsJava ME - 04 - Timer, Tasks and Threads
Java ME - 04 - Timer, Tasks and Threads
 
Java ME - 06 - Record Stores, Distribution and Localization
Java ME - 06 - Record Stores, Distribution and LocalizationJava ME - 06 - Record Stores, Distribution and Localization
Java ME - 06 - Record Stores, Distribution and Localization
 
Lecture 12 os
Lecture 12 osLecture 12 os
Lecture 12 os
 
Threaded Programming
Threaded ProgrammingThreaded Programming
Threaded Programming
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
Symbian OS - Quick Start
Symbian OS - Quick StartSymbian OS - Quick Start
Symbian OS - Quick Start
 
Exception handling and templates
Exception handling and templatesException handling and templates
Exception handling and templates
 
Java ME - 03 - Low Level Graphics E
Java ME - 03 - Low Level Graphics EJava ME - 03 - Low Level Graphics E
Java ME - 03 - Low Level Graphics E
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
 
Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6Bugs from Outer Space | while42 SF #6
Bugs from Outer Space | while42 SF #6
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Crash dump analysis - experience sharing
Crash dump analysis - experience sharingCrash dump analysis - experience sharing
Crash dump analysis - experience sharing
 
Using Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: BasicsUsing Alf with Cameo Simulation Toolkit - Part 1: Basics
Using Alf with Cameo Simulation Toolkit - Part 1: Basics
 
Rust and Eclipse
Rust and EclipseRust and Eclipse
Rust and Eclipse
 

More from Andreas Jakl

Create Engaging Healthcare Experiences with Augmented Reality
Create Engaging Healthcare Experiences with Augmented RealityCreate Engaging Healthcare Experiences with Augmented Reality
Create Engaging Healthcare Experiences with Augmented RealityAndreas Jakl
 
AR / VR Interaction Development with Unity
AR / VR Interaction Development with UnityAR / VR Interaction Development with Unity
AR / VR Interaction Development with UnityAndreas Jakl
 
Android Development with Kotlin, Part 3 - Code and App Management
Android Development with Kotlin, Part 3 - Code and App ManagementAndroid Development with Kotlin, Part 3 - Code and App Management
Android Development with Kotlin, Part 3 - Code and App ManagementAndreas Jakl
 
Android Development with Kotlin, Part 2 - Internet Services and JSON
Android Development with Kotlin, Part 2 - Internet Services and JSONAndroid Development with Kotlin, Part 2 - Internet Services and JSON
Android Development with Kotlin, Part 2 - Internet Services and JSONAndreas Jakl
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndreas Jakl
 
Android and NFC / NDEF (with Kotlin)
Android and NFC / NDEF (with Kotlin)Android and NFC / NDEF (with Kotlin)
Android and NFC / NDEF (with Kotlin)Andreas Jakl
 
Basics of Web Technologies
Basics of Web TechnologiesBasics of Web Technologies
Basics of Web TechnologiesAndreas Jakl
 
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & MoreBluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & MoreAndreas Jakl
 
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?Andreas Jakl
 
Mobile Test Automation
Mobile Test AutomationMobile Test Automation
Mobile Test AutomationAndreas Jakl
 
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...Andreas Jakl
 
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneWinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneAndreas Jakl
 
Nokia New Asha Platform Developer Training
Nokia New Asha Platform Developer TrainingNokia New Asha Platform Developer Training
Nokia New Asha Platform Developer TrainingAndreas Jakl
 
Windows Phone 8 NFC Quickstart
Windows Phone 8 NFC QuickstartWindows Phone 8 NFC Quickstart
Windows Phone 8 NFC QuickstartAndreas Jakl
 
Windows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosWindows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosAndreas Jakl
 
Windows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentWindows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentAndreas Jakl
 
NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)Andreas Jakl
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt CommunicationAndreas Jakl
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and GraphicsAndreas Jakl
 

More from Andreas Jakl (20)

Create Engaging Healthcare Experiences with Augmented Reality
Create Engaging Healthcare Experiences with Augmented RealityCreate Engaging Healthcare Experiences with Augmented Reality
Create Engaging Healthcare Experiences with Augmented Reality
 
AR / VR Interaction Development with Unity
AR / VR Interaction Development with UnityAR / VR Interaction Development with Unity
AR / VR Interaction Development with Unity
 
Android Development with Kotlin, Part 3 - Code and App Management
Android Development with Kotlin, Part 3 - Code and App ManagementAndroid Development with Kotlin, Part 3 - Code and App Management
Android Development with Kotlin, Part 3 - Code and App Management
 
Android Development with Kotlin, Part 2 - Internet Services and JSON
Android Development with Kotlin, Part 2 - Internet Services and JSONAndroid Development with Kotlin, Part 2 - Internet Services and JSON
Android Development with Kotlin, Part 2 - Internet Services and JSON
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Android and NFC / NDEF (with Kotlin)
Android and NFC / NDEF (with Kotlin)Android and NFC / NDEF (with Kotlin)
Android and NFC / NDEF (with Kotlin)
 
Basics of Web Technologies
Basics of Web TechnologiesBasics of Web Technologies
Basics of Web Technologies
 
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & MoreBluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More
Bluetooth Beacons - Bluetooth 5, iBeacon, Eddystone, Arduino, Windows 10 & More
 
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?
Which new scenarios are enabled by Windows 10 for NFC, Bluetooth LE & Beacons?
 
Mobile Test Automation
Mobile Test AutomationMobile Test Automation
Mobile Test Automation
 
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...
Qt App Development - Cross-Platform Development for Android, iOS, Windows Pho...
 
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows PhoneWinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
WinJS, Apache Cordova & NFC - HTML5 apps for Android and Windows Phone
 
Nokia New Asha Platform Developer Training
Nokia New Asha Platform Developer TrainingNokia New Asha Platform Developer Training
Nokia New Asha Platform Developer Training
 
Windows Phone 8 NFC Quickstart
Windows Phone 8 NFC QuickstartWindows Phone 8 NFC Quickstart
Windows Phone 8 NFC Quickstart
 
Windows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosWindows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App Scenarios
 
Windows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentWindows 8 Platform NFC Development
Windows 8 Platform NFC Development
 
NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
04 - Qt Data
04 - Qt Data04 - Qt Data
04 - Qt Data
 

Recently uploaded

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 

Recently uploaded (20)

Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 

Symbian OS - Memory Management

  • 1. Symbian OS Memory Management v2.0a – 21 May 2008 1 Andreas Jakl, 2008
  • 2. Disclaimer These slides are provided free of charge at http://www.symbianresources.com and are used during Symbian OS courses at the University of Applied Sciences in Hagenberg, Austria ( http://www.fh-hagenberg.at/ ) Respecting the copyright laws, you are allowed to use them: for your own, personal, non-commercial use in the academic environment In all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.at The correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not liable for incorrect information or damage that may arise from using the materials. Parts of these materials are based on information from Symbian Press-books published by John Wiley & Sons, Ltd. This document contains copyright materials which are proprietary to Symbian, UIQ, Nokia and SonyEricsson. “S60™” is a trademark of Nokia. “UIQ™” is a trademark of UIQ Technology. Pictures of mobile phones or applications are copyright their respective manufacturers / developers. “Symbian ™”, “Symbian OS ™” and all other Symbian-based marks and logos are trademarks of Symbian Software Limited and are used under license. © Symbian Software Limited 2006. Andreas Jakl, 2008 2
  • 3. Schedule Leaves, Panics and TRAP(D) Cleanupstack ObjectconstructionusingELeave Two-phaseconstruction Debugging tools Andreas Jakl, 2008 3
  • 4. Leaves & Panics Handling problems Andreas Jakl, 2008 4
  • 5. Exceptions – Java Try & Catch for handling exceptions Functions can throw “Exceptions” Andreas Jakl, 2008 5 Integer Class … static intparseIntthrowsNumberFormatException { … } … Calling function Try { int x = Integer.parseInt(“1234”); } catch (NumberFormatException e) { System.out.println(“Unable to convert this String to a number.”); }
  • 6. Leave – Symbian TRAP(D) catches exceptions (“Leave”) Functions send out leave Function name marked by an L-suffix Andreas Jakl, 2008 6 The TRAP(D) macros are defined in e32cmn.h Main-Function TRAPD(err, DoExampleL());if (err) { console->Printf(KTxtFailed, err); } DoExampleL()-Function voidDoExampleL() {RFsfsSession; // Connect to the file serverUser::LeaveIfError(fsSession.Connect()); // …fsSession.Close(); } TRAPD-Makro declares err as TInt and = KErrNone Leaves if the Connect() function does not return KErrNone
  • 7. Central ExceptionHandling Andreas Jakl, 2008 7 New (ELeave) … … NewL() … … User::Leave() … … ConstructL() … F6L() F7L() F8L() F9L() F5L() F5L() … … F6L() …. … F8L() …. F3L() F4L() F0L() F2L() … F3L() … F4L() … F1L() TRAPD(err, F2L()); if(err) …
  • 8. Handling Leaves Try to implement central leave-handling If leave not handled by your code  error-message shown by the UI-framework! Therefore: Only handle leaves yourself if they influence your application Andreas Jakl, 2008 8
  • 9. When can a function leave? Caused by your own code: User::Leave(), User::LeaveIfError(), User::LeaveNoMemory() or User::LeaveIfNull() Failed object-construction when using the “new (ELeave)”-operator Calling a function that potentially causes a leave e.g. x->DoSomethingL() Andreas Jakl, 2008 9
  • 10. Details: Causing a Leave User::Leave(TIntaReason) Error code (aReason) = value that will be received by TRAP Causes leave in any case User::LeaveIfError(TIntaReason) Causes leave if parameter is negative, e.g.:TIntfoundAt = iElementArray.Find(example, aRelation);User::LeaveIfError(foundAt); // Leaves if foundAt == KErrNotFound (-1) User::LeaveNoMemory() Is the same as: User:Leave(KErrNoMem); User::LeaveIfNull(TAny* aPtr) Andreas Jakl, 2008 10
  • 11. TRAP / TRAPD Two trap harness macros: TRAP: declares the variable in which the leave code is returned TRAPD: declare a TIntvariable yourself If a leave occurs inside MayLeaveL(), which is executed inside the harness, the program code will return immediately to the TRAP harness macro The variable result will contain the error code associated with the leave or will be KErrNoneif no leave occured Andreas Jakl, 2008 11 TRAPD(result, MayLeaveL()); if (KErrNone!=result) ... is equivalent to: TIntresult; TRAP(result, MayLeaveL()); if (KErrNone!=result) ...
  • 12. Tips Andreas Jakl, 2008 12 X voidInsertData() { TInt err; TRAP(err, iData->InsertL(23)); if (err) { ... } TRAP(err, iData->InsertL(24)); if (err) { ... } } TRAPs are expensive Don’t use several TRAPs right after each other Instead: Make the function leave (append an L to the function name) Handle all errors in a single TRAP-call one level above! In UI apps, many leaves don’t have to be handled by you  they can go up to the topmost level (= Active Scheduler) prefer  voidHandleCommand() { TRAPD(err, InsertDataL()); if (err) { ... } } voidInsertDataL() { iData->InsertL(23)); iData->InsertL(24)); }
  • 13. Panics ... cannot be caught and handled! Terminates thread (= usually the whole application) Use them for checking code logic only Can also be sent out by the system for critical errors If a panic happens: Make sure you fix it, as you can’t handle it! Andreas Jakl, 2008 13 // Stray signal detected! _LIT(KMsgStraySignal, "Stray signal"); User::Panic(KMsgStraySignal, 1); // Panic with code 1
  • 14. Resource Handling Stack, Heap and the Cleanup Stack Andreas Jakl, 2008 14
  • 15. Practice in a Nutshell All strategiesarepresent in thisfunction: Andreas Jakl, 2008 15 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }
  • 16. Recap: Stack Andreas Jakl, 2008 16 // Stack (1) voidCTest::F1() { TInt x = 0; TInt y = 1; for(x = 0; x < 10; x++) y++ y = y + F2(); // Stack (4) } // Stack (5) TIntCTest::F2() { TInt a = 2; TInt b = 1; return a + b; // Stack (3) } Stack (2) Stack (5) Stack (1) TInt y TInt x F1 Stack (2) TInt y TInt x F1 Stack (4) TInt b TInt a F2 TInt y TInt x F1 Stack (3)
  • 17. Recap: Heap Use for: Objects that need a lot of memory ( stack-size is limited!) Required amount of memoryonlyknown at runtime Scope of heap-objects is not limited to a function Use pointers to pass to other functions/objects Andreas Jakl, 2008 17
  • 18. Motivation Symbian OS designed to run for many years  No opportunity to reclaim leaked memory through regular restarts! Small memory leaks accumulate over time We only have a small memory to start with Therefore: Simply write perfect, leak-free code! Andreas Jakl, 2008 18
  • 19. Motivation – How? By keeping track of all allocated objects! By making sure: All heap-objects are pointed to by at least one pointer, all the time – even in the constructor of an object! Free heap memory as soon as possible after use. Andreas Jakl, 2008 19
  • 20. The Cleanup Stack Safeguard Andreas Jakl, 2008 20
  • 21. Resource Handling – Rule 1 Andreas Jakl, 2008 21 Every local pointer to an instance of a heap-based object also has to be pushed on the cleanup stack, if there‘s the risk that the pointer gets lost because of a leave.
  • 22. Cleanup Stack Situation: function creates local heap-object Before code gets to the delete-statement: error Function is left (Leave) Pointer-address on the stack is freed Object itself is orphaned memory leak! Andreas Jakl, 2008 22 voidCImage::DoSomethingDangerousL() { User::Leave(KErrNotFound); } CImage voidCMyObj::DoSomethingL() { } CImage* img = new (ELeave) CImage(); img->DoSomethingDangerousL(); deleteimg; img = pointer on the stack to an instance on the heap
  • 23. Cleanup Stack Memory situation if a leave occurs: Andreas Jakl, 2008 23 ! X X img Heap Stack Object stays on the heap;Pointer to delete the instance is lostmemory leak
  • 24. Cleanup Stack Solution: Cleanup Stack Andreas Jakl, 2008 24 void CMyObj::DoSomethingL() { CImage* img = new (ELeave) CImage(); CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); } img  CleanupStack X X img Heap Stack When no leave occurs: object still has to be deleted by you + removed from the cleanup stack! Cleanup stack saves a second pointerto the object on the heap.
  • 25. AdvancedCleanup Andreas Jakl, 2008 25 RFile Forresourcesthathavetobeclosed / freed(e.g.: files, sockets, …) Close(): CleanupClosePushL(T&) Release(): CleanupReleasePushL(T&) Destructor: CleanupDeletePushL(T*) Close() TCleanupOperation TAny* aPtr … TCleanupItem CleanupStack
  • 26. AdvancedCleanup – Example Andreas Jakl, 2008 26 voidCMyClass::TransferDataL() { RSocketServsocketServer; // Connect to SocketServer User::LeaveIfError( socketServer.Connect() ); // Make sure Close() is called at the end CleanupClosePushL( socketServer ); // … CleanupStack::PopAndDestroy(); // socketServer }
  • 27. Cleanup Stack and Ownership Transfer It should never be possible for an object to be deleted more than once! Andreas Jakl, 2008 27 voidTransferOwnershipExampleL() { // The stack variable ptr points to memory allocated on the heap CItem* ptr = new (ELeave) CItem(); // The following function may leave -> place the pointer on the // cleanup stack, so that the heap memory is freed in case // AppendL() leaves. CleanupStack::PushL(ptr); // iItemPtrArray takes ownership of the CItem object. // This could fail, as it needs to allocate a new slot to store the pointer, // therefore the object was placed on the cleanup stack in advance iItemPtrArray->AppendL(ptr); // iItemArray now owns the heap object, so ptr may be safely popped off the stack. // It shouldn’t be destroyed, as this would make the item in iItemPtrArray invalid! CleanupStack::Pop(ptr); }
  • 28. Practice in a Nutshell Strategiesexplaineduptonow: Andreas Jakl, 2008 28 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }  
  • 29. Resource Handling – Rule 2 Andreas Jakl, 2008 29 Never push instance variables on the cleanup stack! The owning class is also on the cleanup stack somewhere (at least indirectly). This would lead to a double deletion of the object pointed to by the instance variable  Panic!
  • 30. Coding Error Example Andreas Jakl, 2008 30 class CSimple : CBase { public: ~CSimple(); void MayLeaveFuncL(); private: void PrivateMayLeaveL(); CItem* iItem; }; CSimple* simple = new (ELeave) CSimple(); CleanupStack::PushL(simple); 1. CSimple is created and pushed onto the cleanup stack as the next function may leave TRAPD(res,simple->MayLeaveFuncL()); ... 2. A leaving method is called on simple void CSimple::MayLeaveFuncL() { iItem= new (ELeave) CItem(); CleanupStack::PushL(iItem); PrivateMayLeaveL(); CleanupStack::Pop(iItem); } 3. The member variable is pushed onto the clean up stack (oops!) 5. The TRAP does the right thing and clears the cleanup stack; i.e. CSimple::iItem is deleted 4. What happens if a leaves occurs? ... 6. The code logic completes with the popping and deleting of the simple object. CleanupStack::PopAndDestroy(simple); CSimple::~CSimple { delete iItem; } BUT this calls the CSimple destructor, which deletes the iItem which has already been deleted by the TRAP 7. PANIC! Example taken from theSymbian Academy slides
  • 31. Object Construction Leave-handling during Andreas Jakl, 2008 31
  • 32. New Objects new-operator allocates memory and runs constructor Returns null-pointer if object creation fails(e.g. not enough memory)  manual test required to see if it was successful – no automated leave! Andreas Jakl, 2008 32 void CMyObj::DoSomethingL() { CImage* img = newCImage(); if (img) { CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); } else { User::LeaveNoMemory(); } }
  • 33. New Objects – ELeave Andreas Jakl, 2008 33 void CMyObj::DoSomethingL() { CImage* img = newCImage(); if (img) { CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); } else { User::LeaveNoMemory(); } } void CMyObj::DoSomethingL() { CImage* img = new (ELeave)CImage(); CleanupStack::PushL(img); img->DoSomethingDangerousL(); CleanupStack::PopAndDestroy(); } identical new-Operator overloaded with ELeave: automated leave if there’s not enough memory!
  • 34. Practice in a Nutshell Strategiesexplained so far: Andreas Jakl, 2008 34 CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }   
  • 35. Two-Phase Construction The ultimate combination … Andreas Jakl, 2008 35
  • 36. Resource Handling – Rule 3 Andreas Jakl, 2008 36 Neither a constructor nor a destructor may cause a leave! The destructor must not assume that the object was fully initialized.
  • 37. Leaves in the Constructor Andreas Jakl, 2008 37 1. Call to constructorof CEngine Application CEngine* myEngine = new (ELeave) CEngine(); … … CEngine CEngine::CEngine() { iList = new (ELeave) CList(); } CEngine::~CEngine() { deleteiList; } iList CEngine 2. Leave – nomemory left for allocating iList Heap 3. Because of the leavethere is no valid pointerto the partially constructedCEngine-object. 4. Without a validpointer, the memoryalready allocatedfor CEngine is lost. ?
  • 38. Solution: Two-phase Construction Andreas Jakl, 2008 38  Application CEngine* myEngine = new (ELeave) CEngine();CleanupStack::Push(myEngine); myEngine->ConstructL(); … // Note that the following line won’t be // reached in case of a leave!CleanupStack::PopAndDestroy(myEngine); CEngine CEngine::CEngine() {// 1. Phase } CEngine::ConstructL() {// 2. Phase iList = new (ELeave) CList(); } CEngine::~CEngine() { deleteiList; } iList CEngine Heap Object is fully allocated and on the cleanup stack  the destructor can be executed, the class is deleted by the cleanup stack  all memory is properly cleaned up in case of a leave!
  • 39. Simplification: Two-phase Construction Less complicated creation of objects: Trailing C at the end of the function name: an object is left on the cleanup stack (as in NewLC()) Andreas Jakl, 2008 39 CEngine CEngine* CEngine::NewLC() {CEngine* self = new (ELeave) CEngine(); // 1. PhaseCleanupStack::PushL(self); self->ConstructL(); // 2. Phase return self; } CEngine* CEngine::NewL() { CEngine* self = CEngine::NewLC(); CleanupStack::Pop(self); return self; } Application – Local Variable CEngine* myEngine = CEngine::NewLC(); … CleanupStack::PopAndDestroy(myEngine); or Application– Instance Variable iMyEngine = CEngine::NewL(); Destructor: delete iMyEngine; Application – Instance variable iMyEngine = CEngine::NewL(); // Destructor: deleteiMyEngine;
  • 40. Practice in a Nutshell Strategiesexplained so far: Andreas Jakl, 2008 40  CClass* CClass::NewL(TIntaInt, CBase& aObj) { CClass* self = new (ELeave) CClass(aInt); CleanupStack::PushL(self); self->ConstructL(aObj); CleanupStack::Pop(self); returnself; }     
  • 41. Derivation Note: Some thoughts are necessary when deriving from a class that uses two-phase construction See the literature or Symbian Academy-slides for details! Andreas Jakl, 2008 41
  • 42. Resource Handling – Rule 4 Andreas Jakl, 2008 42 If memory for a pointer (instance variable) is reallocated, set the old pointer to NULL beforehand.
  • 43. NULL Situation (without NULL): AllocL() causes a leave, which propagates up … Instance of CElement is deleted Destructor of CElement is called iName still points to already deleted memory Deleted 2x  Panic Andreas Jakl, 2008 43 voidCEngine::DoStuffL(constTDesC& aName) { CElement* element = CElement::NewLC(); TRAPD(err, element->SetNameL(aName)); CleanupStack::PopAndDestroy(element); } 2 1 voidCElement::SetNameL(constTDesC& aName) { deleteiName; // Deletes object, does not change pointer iName = aName.AllocL(); // Re-Allocation } voidCElement::~CElement() { deleteiName; } 1 2 iName = NULL; // Deletes pointer on stack Note: delete does not delete a NULL pointer.
  • 45. Summary Catch leaves (= exceptions) with TRAP(D) Use cleanup stack for local heap-based variables Do not use the cleanup stack for instance variables No leaves in constructors or destructors Use two-phase construction for objects with data on the heap Set a pointer to NULL before re-allocating memory Andreas Jakl, 2008 45 !
  • 46. What’s wrong? Andreas Jakl, 2008 46 CleanupStack::PushL(iList);
  • 47. What’s wrong? Andreas Jakl, 2008 47 CleanupStack::PushL(iList); Never push instance variables on the cleanup stack! Twice as safe isn’t safe at all…
  • 48. What’s wrong? Andreas Jakl, 2008 48 CEngine* engine = new (ELeave) CEngine();…CleanupStack::PopAndDestroy(engine)
  • 49. What’s wrong? Andreas Jakl, 2008 49 CEngine* engine = new (ELeave) CEngine();…CleanupStack::PopAndDestroy(engine) enginewasn‘t pushed on the cleanup stack!new (ELeave) is only responsible for leaving if memory allocation for the object fails. new (ELeave) has nothing to do with the cleanup stack. Solution: Either: add the object to the cleanup stack: CleanupStack::PushL(engine); Or: don’t use the cleanup stack for deleting – in case no leaving operation is called between creation and deletion of the engine object: delete engine;
  • 50. What’s wrong? Andreas Jakl, 2008 50 voidCGomokuViewGame::ChangeViewContextText(TIntaResourceId) { RBufnewText(iEikonEnv->AllocReadResourceL(resourceId)); newText.CleanupClosePushL (); MQikViewContext* viewContext = ViewContext (); // Changing an alreadyexistingviewcontexttext viewContext->ChangeTextL (EGomokuViewContext, newText); CleanupStack::PopAndDestroy (1); // newText }
  • 51. What’s wrong? Andreas Jakl, 2008 51 void CGomokuViewGame::ChangeViewContextText(TInt aResourceId) { RBuf newText(iEikonEnv->AllocReadResourceL(resourceId)); newText.CleanupClosePushL (); MQikViewContext* viewContext = ViewContext (); // Changing an already existing view context text viewContext->ChangeTextL (EGomokuViewContext, newText); CleanupStack::PopAndDestroy (1); // newText } The trailing L of the function name is missing, as calls within the function can leave. Solution:void CGomokuViewGame::ChangeViewContextTextL(…)
  • 52. Testing your Code On your way to perfection Andreas Jakl, 2008 52
  • 53. Macros for Testing Wrap code you want to test within __UHEAP_MARK and __UHEAP_MARKEND: Andreas Jakl, 2008 53 CClass* p1 = new (ELeave) CClass; __UHEAP_MARK;// Mark start of test-area CClass* p2 = new (ELeave) CClass; CClass* p3 = new (ELeave) CClass; __UHEAP_CHECK(2);// 2 Objects (p2, p3) on the heap since the start-mark __UHEAP_CHECKALL(3);// In total 3 objects on the heap delete p3; _UHEAP_MARKEND;// Result: p2 is still here – Memory Leak! // or: __UHEAP_MARKENDC(1);// Expects one cell on the heap
  • 54. Finding Memory Leaks Emulator checksheapautomaticallyifyouexittheprogram BEFORE closingtheemulatorwindow! Andreas Jakl, 2008 54 Find it in theSymbian OS SDK doc: Symbian OS SDK v…  Symbian OS guide  Symbian OS reference  System panicreference
  • 55. Memory Information Show numberofallocatedcells: Ctrl+Alt+Shift+A Andreas Jakl, 2008 55
  • 56. Allocation Failure Intentional failing of memory allocation: __UHEAP_SETFAIL(aType, aValue); EDeterministic: fail every nth request ERandom: fail randomly once within a specified range – always using the same seed ETrueRandom: random seed taken from system time Andreas Jakl, 2008 56 __UHEAP_SETFAIL(RHeap::EDeterministic, 2); CObj* c1 = new (ELeave) CObj; // will allocate CObj* c2 = new (ELeave) CObj; // will fail CObj* c3 = new (ELeave) CObj; // will allocate CObj* c4 = new (ELeave) CObj; // will fail __UHEAP_RESET; // Deactivate
  • 57. FAILNEXT Fails thenextallocationrequest Andreas Jakl, 2008 57 CObj* c1 = new (ELeave) CObj; // will allocate __UHEAP_FAILNEXT(1);// failnextallocation CObj* c2 = new (ELeave) CObj; // will fail
  • 58. AllocationFailure In theemulator, withoutwritingcode: Heap Failure Tool Activate:Ctrl+Alt+Shift+P Deactivate:Ctrl+Alt+Shift+Q Can failheap, WindowServer-allocationsorfile-access Andreas Jakl, 2008 58
  • 59. … let’s move to the Challenges! Try it for your own Andreas Jakl, 2008 59