fix gh-571: sophia: memory leak issue