I always loved the C language, it is a pure passion for me, I always use this fantastic language when I need to develop real time applications.
These days, I am very focused on my new 3D engine called PATRIA and I am now doing some housekeeping procedures in order to avoid memory leaks and optmize the engine to run on handheld devices that, obviously are very limited in terms of resources avaialable.
Well, to cut a long story short, I was working on the PATRIA Objects memory release from the main Objects chain at the end of a game level played…..well, the engine worked smoothly on my Linux Desktop but, once ported on Android it started to crash.
Now, I have to say that I love the C language for its power and the flexibility that the memory pointers give you but I have to admit that, when something going wrong, it is a real pain in the neck.
To cut a long story shot (I started this topic yesterday and Today I don’t even understand why I have initiated it), I found out where the error was.
It was depending on the way I have linked one of the thousands memory pointers in the PATRIA Engine core chain.
In fact, all of the pointers were the result of a malloc operation while one of the item was a memory pointer reference to a statically declared variable.
Well, this was the problem, on Linux using gcc, the compiler was good (bad) enough to identify the problem and go on, on Android, still using gcc, the program crashed at runtime level.
I spent 2 full days and a lot of headache but in the end, I won!
Lesson learnt: When you have a run time error during a free operation, always check that you are not deallocating a statically allocated memory segment! it is an error!