revert 00a8e692f87a0f3bce8cf4dc089d0aaf61c63c6a / memleaks

possible fixes #4140