File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ void main() async {
22
22
print (model);
23
23
24
24
final ctx = await llama.newContext (model, params);
25
- // await llama.freeContext(ctx);
25
+ await llama.freeContext (ctx);
26
26
27
27
await llama.freeModel (model);
28
28
llama.dispose ();
@@ -104,9 +104,9 @@ class Llama {
104
104
return resp.ctx! ;
105
105
}
106
106
107
- // Future<void> freeContext(Context ctx) async {
108
- // final ctl = FreeContextCtl(ctx);
109
- // _controlPort.send(ctl);
110
- // await _response.firstWhere((e) => e is FreeContextResp && e.id == ctl.id);
111
- // }
107
+ Future <void > freeContext (Context ctx) async {
108
+ final ctl = FreeContextCtl (ctx);
109
+ _controlPort.send (ctl);
110
+ await _response.firstWhere ((e) => e is FreeContextResp && e.id == ctl.id);
111
+ }
112
112
}
Original file line number Diff line number Diff line change @@ -201,8 +201,10 @@ class Model {
201
201
}
202
202
203
203
class Context {
204
- final int rawPointer;
205
- const Context ._(this .rawPointer);
204
+ final int _rawPointer;
205
+ const Context ._(this ._rawPointer);
206
+ Pointer <llama_context> get _ffiPointer =>
207
+ Pointer .fromAddress (_rawPointer).cast <llama_context>();
206
208
}
207
209
208
210
class _Allocations <E > {
@@ -313,5 +315,7 @@ void _onControl(ControlMessage ctl) {
313
315
_response.send (ctl.done (Context ._(rawCtx)));
314
316
315
317
case FreeContextCtl ():
318
+ libllama.llama_free (ctl.ctx._ffiPointer);
319
+ _response.send (ctl.done ());
316
320
}
317
321
}
You can’t perform that action at this time.
0 commit comments