Here is some suggestions that may help you with it.
This is applicable to mobile development:
1. All resources line memory allocation, files, etc., you need to put in a wrapper: shared_ptr
2. All unexpected behavior line "low memory" should throw an exception and exit.
class MyDataBlock
{
char* mData;
public:
MyDataBlock():mData(NULL){}
MyDataBlock():mData(int size)
{
ASSERT(size>0,"wrong size");
mData = new char[size];
ASSERT(mData,"low memory");
}
~MyDataBlock()
{
delete[] mData;
}
}
3. Logs
- developer logs - you must have them if there is no way to run application in debug mode. This is more applicable to OS driver development or other specific domain development.
- when exception happen try to log stack. When application crashes it is very useful to have function calls stack.
No comments:
Post a Comment