fix the memory leak issue

@tklein23 @karlnapf 
Fix the memory leak
The variational example will be sent once the variational likelihood classes are merged because I use some methods in these new classes.