Do I need to do something to ensure bytes is released, since it doesn't seem to be happening on its own?
Definitely! See this note in the documentation for UnsafeMutablePointer.allocate(capacity:):
When you allocate memory, always remember to deallocate once you’re finished.
The Unsafe in the name is a reminder you’re in old-school C land now, where you need to free() at some point after every malloc().
Topic:
Programming Languages
SubTopic:
Swift
Tags: