Memory Management Improvements #148

Merged
erinn merged 2 commits from memory into trunk 2021-08-25 19:37:17 +00:00
Owner

Free Pointers Allocated by NativeUTF8

Also use new c_FreePointer from libCwtch to free returned strings
after they have been processed.

Requires cwtch.im/libcwtch-go#19

Free Pointers Allocated by NativeUTF8 Also use new c_FreePointer from libCwtch to free returned strings after they have been processed. Requires https://git.openprivacy.ca/cwtch.im/libcwtch-go/pulls/19
dan was assigned by sarah 2021-08-25 05:08:26 +00:00
erinn was assigned by sarah 2021-08-25 05:08:31 +00:00
sarah force-pushed memory from ed43063a61 to 3cf81e41d6 2021-08-25 05:11:05 +00:00 Compare
dan reviewed 2021-08-25 16:17:40 +00:00
dan left a comment
Owner

aside from one comment I think this looks good to me

kinda wish there was a more meta programming way to tackle this, like a generic function caller function we could write... but I can't think of anything off the top of my head... unless we want a 3rd set or argument sized fns to go with the pointers like mem_safe_invoke_1str, mem_safe_invoke_2str etc etc etc

then move the function pointer loading to Start() and store them all in the class and wrap them there too

aside from one comment I think this looks good to me kinda wish there was a more meta programming way to tackle this, like a generic function caller function we could write... but I can't think of anything off the top of my head... unless we want a 3rd set or argument sized fns to go with the pointers like mem_safe_invoke_1str, mem_safe_invoke_2str etc etc etc then move the function pointer loading to Start() and store them all in the class and wrap them there too
@ -138,9 +130,7 @@ class CwtchFfi implements Cwtch {
// Called on object being disposed to (presumably on app close) to close the isolate that's listening to libcwtch-go events
@override
void dispose() {
if (cwtchIsolate != null) {
Owner

why remove? the isolate isn't assigned till Start() so there is a theoretical chance it could be null when called. Also I think we might have put that in when we were covering our asses about trying to gracefully shutdown and putting shutdown calls in multiple places so as to prevent it getting double unallocated and segfaulting on "graceful" exit

why remove? the isolate isn't assigned till Start() so there is a theoretical chance it could be null when called. Also I think we might have put that in when we were covering our asses about trying to gracefully shutdown and putting shutdown calls in multiple places so as to prevent it getting double unallocated and segfaulting on "graceful" exit
Author
Owner

Flutter linting declares this check as unnecessary. CwtchIsolate can never assigned to null after it is initialized.

Flutter linting declares this check as unnecessary. CwtchIsolate can never assigned to null after it is initialized.
@ -414,0 +467,4 @@
// ignore: non_constant_identifier_names
// Incredibly dangerous function which invokes a free in libCwtch, should only be used
// as documented in `MEMORY.md` in libCwtch repo.
void _UnsafeFreePointerAnyUseOfThisFunctionMustBeDoubleApproved(Pointer<Utf8> ptr) {
Owner

LOL

LOL
sarah added 1 commit 2021-08-25 17:00:03 +00:00
continuous-integration/drone/pr Build is passing Details
6d4ab5bab3
Upgrade libcwtch-go
sarah changed title from WIP: Memory Management Improvements to Memory Management Improvements 2021-08-25 17:00:32 +00:00
Member
Drone Build Status: success https://build.openprivacy.ca/cwtch.im/cwtch-ui/179
dan approved these changes 2021-08-25 17:47:06 +00:00
erinn approved these changes 2021-08-25 19:37:01 +00:00
erinn merged commit b78f138cb2 into trunk 2021-08-25 19:37:17 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/cwtch-ui#148
No description provided.