Azathoth #1 The program calling ToCString or ToWString should be the one freeing the memory, if your Dll does it that will make it incompatible with other programming languages.