-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement into_memory for memory manager #188
Conversation
@bitdivine Can you share what your use-case is? |
@ielashi Sure thing: I am migrating from raw memory to stable structures and back again. Migrating back involves getting the raw memory back from the managed memory - or keeping a second reference. With a wrapper that keeps both managed memory and a second pointer, I also found that this simplifies unit testing schema upgrades. Restarting the "canister" in tests is then just a matter of getting the raw memory back, and that raw memory is then loaded in the upgraded canister. I don't need an entire replica for this. This was not the original motivation but was a nice bonus! :-) |
@bitdivine The issue was actually more complex to fix than excepted, but it's finally resolved. PR LGTM! :) |
|
@ielashi Thank you! I do not have permission to merge but CI is green. |
Motivation
When a memory manager is created, the constructor (
init()
) consumes the undertlying memory and there is no way of getting it back.A workaround is to clone a reference to the memory and keep the reference around, however that opens the possibility that the underlying memory is changed without going via the memory manager. It would be better if the memory manager could be made to surrender the underlying memory.
Changes
into_inner()
toMemoryManager
(and to the inner data structure).Tests