memfree is the correct way to free bytePtr memory.
But I fear such kind of problems somewhere were to be expected. DLL support is not officially in nor ever mentioned to be anywhere near stable. So what you do is alpha test the feature most likely.
I'm quite a BM fan, but for DLL I would suggest using PureBasic, because its threadsafe and supports threads and mutexes. Don't know when or if this will ever be added to BM.
But I fear such kind of problems somewhere were to be expected. DLL support is not officially in nor ever mentioned to be anywhere near stable. So what you do is alpha test the feature most likely.
I'm quite a BM fan, but for DLL I would suggest using PureBasic, because its threadsafe and supports threads and mutexes. Don't know when or if this will ever be added to BM.