Symbian Memory Management 222 military rules 2005-01-12 Views: 98
1. Class C must have a destructor, which is a virtual function of CBase.
2, Class C constructor and constructL () must be a member function for protect or private type
3. There must be a newlc () function in the C class unless it is a nested class. NEWL () is optional and is always implemented according to NEWLC ().
4, newl () and newlc () must be a Static function in Class Class.
5, Class C pass through pointers and references.
6. The copy constructor is useless in Symbian.
7. Do not have to delete a member object of the class in the destructor. (Delete can be deleted in the life of the life)
8. The object must be checked in the destructor. which is
IOBJECT DELETE IObject; IObject = NULL;
9, the R Class does not have a clear constructor, destructure or copy constructor and assignment operation.
10, delete a; a = null; a = b; standard redistribution process.
11. Any function that can lead to an abnormally exit is a suffix.
12, don't delete non-owners (that is, those only use only)
13. Define a suitable particle size before distributing a dynamic array.
14, replace the New to New (Eleave).
15, if (function cannot abnormally exit && want to handle errors) Use Trap && not too much nested.
16, IF (AObject is referenced by an automatic variable pointer && will perform a possible operation in AOBJECT survival)
Cleanupstack :: Pushl (AOBJECT);
17. Never put a member variable of a prefix into the stack.
18, the constructor can not Leave, put the statements that may be abnormally exited into constructl ().
19, Symbian's default stack capacity is 8K, carefully use recursive.
20, the length of TBUF is preferably not over 16, and if necessary, use HBUFC instead of TBUF.
21. Use __uheap_maek macro to detect your memory.
22. To remove everything you lose use, don't wait until the end (auto variable) or delete (member variable) in the destructor.