Open Froxcey opened 4 hours ago
I found the fix, just need to do
pub fn toBytes(self: Self) []u8 {
var p: c.struct_ByteArray = c.Mat_ToBytes(self.ptr);
+ defer c.free(p.data);
const len = @as(usize, @intCast(p.length));
return p.data[0..len];
}
in src/core/mat.zig
https://github.com/Froxcey/zigcv/commit/8076f266f97aa867f2c1dfc5e0465fe0cc4ce8d3
In my code base, I'm calling mat.toByte() every frame Since that function allocates memory on heap, it causes memory leak Is there a way to do something like