Likely it's because you don't create your model on the heap! It is destroyed after you leave the scope. (Unless your code is not in your main function.)