I’m seeing the same things: the memory will peak and then get released.
Throwing in a time.sleep(.) call and then checking the memory (in the toy example only) has been released seems to reliably bring the allocated memory amount back to the original state.
Doing something similar in my original problem doesn’t seem to help, however. So I can safely assume that it’s not just a problem with some delay in deallocation.