nandi/vflutter_ffipublic Fork 0
4506a586d7400b00d732dcb97167be75ab41cab1
Commits
Clone
git clone https://git.rickub.com/nandi/vflutter_ffi.git
git clone ssh://git@rickub.com/nandi/vflutter_ffi.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

memory_check.dart · 21 lines · 861 BDart Blame HistoryRaw
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 15h ago1import 'dart:ffi';
2import 'dart:io';
3import 'package:ffi/ffi.dart';
4int rss() => int.parse(File('/proc/self/status').readAsLinesSync()
5 .firstWhere((l)=>l.startsWith('VmRSS')).split(RegExp(r'\s+'))[1]);
6
7void main(){
Replace V with Nim 472eb49 nandithebull 9h ago8 final lib = DynamicLibrary.open('libnimflutter.so');
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 15h ago9 final greet = lib.lookupFunction<Pointer<Utf8> Function(Pointer<Utf8>),
Replace V with Nim 472eb49 nandithebull 9h ago10 Pointer<Utf8> Function(Pointer<Utf8>)>('nf_greet');
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 15h ago11 final vfree = lib.lookupFunction<Void Function(Pointer<Void>),
Replace V with Nim 472eb49 nandithebull 9h ago12 void Function(Pointer<Void>)>('nf_free');
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 15h ago13
Replace V with Nim 472eb49 nandithebull 9h ago14 // Regression guard for the shared-heap ownership rule: RSS must stay flat.
Initial commit: V -> Flutter FFI plugin ad0ccda nandi 15h ago15 final arg = 'fixed'.toNativeUtf8();
16 for (var i=0;i<5000;i++){ vfree(greet(arg).cast()); }
17 final before = rss();
18 for (var i=0;i<900000;i++){ vfree(greet(arg).cast()); }
19 print('native-only before: $before kB after: ${rss()} kB');
20 calloc.free(arg);
21}