Here is a simple example explaining the usage of strong and weak pointers using android's RefBase class and the Android.mk to compile the same. Its a modified version of code written by Daniel in the following link. http://himmele.blogspot.com/2012/03/androids-c-reference-counting.html strong_pointer.cpp file: #include <stdio.h> #include "utils/RefBase.h" namespace android { class RefTest : public RefBase { public: RefTest(int32_t id) : mID(id) { printf("RefTest ctor: %d\n", mID); } virtual ~RefTest() { printf("RefTest dtor: %d\n", mID); } int32_t id() const { return mID; } private: int32_t mID; }; int strong_pointer() { sp<RefTest> ref1 = new RefTest(1); sp<RefTest> ref5; ...