-
-
Notifications
You must be signed in to change notification settings - Fork 25
Improve performance and optimize memory #67
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
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #67 +/- ##
==========================================
+ Coverage 88.97% 89.50% +0.53%
==========================================
Files 36 36
Lines 4897 5165 +268
==========================================
+ Hits 4357 4623 +266
- Misses 540 542 +2 ☔ View full report in Codecov by Sentry. |
Ready to merge. Note:
Example: import 'package:opencv_dart/opencv_dart.dart' as cv;
void main() {
const counts = 10000;
final mat = cv.Mat.zeros(1000, 1000, cv.MatType.CV_8UC3);
final sw = Stopwatch()..start();
for (var count = 0; count < counts; count++) {
final mat1 = cv.cvtColor(mat, cv.COLOR_BGR2YCrCb);
// manually dispose will reduce the memory consumption
mat1.dispose();
}
sw.stop();
print(
"All: ${sw.elapsedMicroseconds}μs, counts: $counts, per: ${sw.elapsedMicroseconds / counts} μs");
}
Without All: 5527358μs, counts: 10000, per: 552.7358 μs With All: 7263633μs, counts: 10000, per: 726.3633 μs |
Does this mean the package user will have to manage the object? I another way do I have to dispose every native asset I use? |
Not necessary, the above test is for dart, I didn't test in Flutter but Flutter will trigger GC more frequently than pure dart, so it tends to rely on GC to free, BUT, if users can know that the APP will process large images (e.g., 3840*2160*3), it's recommend to dispose manually. Anyway, this PR just provides a potential to manage native resources more efficiently according to the weakness of the GC of dart VM, but not necessary. |
Oh got it , so GC works too but if needed manual mode can be used for optimization |
bingo! |
Reduce the consumption, improve performance