fix memory leak in _writeData method
Merge pull request #1 from Tratar/memory_leak_fix

fix memory leak in _writeData method