Comments (11)
@GNUGradyn
Thank you for your good investigation.
I'll try to reproduce it,
from dlibdotnet.
NOTE
return of NativeMethods.array2d_row
would not be disposed
from dlibdotnet.
Row should receive row
in constructor and Row[index] use row
and columns
.
It should take a bit more time but does not use unnecesarry memory.
from dlibdotnet.
@GNUGradyn
Could you try the following code?
using DlibDotNet;
while (true)
{
var test = new Array2D<RgbPixel>(10, 10);
var row = test[0];
row[0] = new RgbPixel
{
Red = 0,
Green = 0,
Blue = 0
};
row.Dispose();
test.Dispose();
}
I think it works.
from dlibdotnet.
@takuya-takeuchi thank you for the quick response. This does work, but it feels like more of a workaround then a solution. When using an Array2D to store an image for facial recognition for an example, you would have to iterate thru and dispose every row when you are done (could be over 1000 rows for a higher resolution image). This could really start to add up if you are processing several frames to track a moving face, especially considering how often GC has to run when you are disposing of thousands of objects constantly.
If this is unavoidable, the library should at least do this automatically when you dispose the Array2D
from dlibdotnet.
I'm not really sure why but this solution also does not appear to work when creating/disposing rows in a loop
using DlibDotNet;
while (true)
{
var test = new Array2D<RgbPixel>(10, 10);
// Make some rows
for (var i = 0; i < 10; i++)
{
var row = test[i];
row[0] = new RgbPixel
{
Red = 0,
Green = 0,
Blue = 0
};
}
// Delete all the new rows
for (var j = 0; j < 10; j++)
{
var row = test[j];
row.Dispose();
}
test.Dispose();
}
from dlibdotnet.
Matrix
does not appear to have the same issue. Simply disposing of a Matrix
works as you'd expect.
from dlibdotnet.
Using a Matrix
appears to hit the garbage collector pretty hard, but not quite hard enough to create a GC pressure memory leak. This is an acceptable workaround
from dlibdotnet.
var row = test[i];
After execute this, Row is generated. Row has unmanaged object.
So this object shall be disposed every time.
If this is unavoidable, the library should at least do this automatically when you dispose the Array2D
Yes, I agree with you.
So I will fix Array[int][int].
Thanks.
from dlibdotnet.
@GNUGradyn
I fixed issue.
1. Keep current interface Array2D[int row]
This interface intents to let developer access to column value efficiently.
For example
using (var row = array[0])
{
for (var c = 0; array.Columns; c++)
Console.WriteLien(row[c]);
}
Row holds native pointer to improve performance.
So developer shall take care of usage of this property.
2. Add new interface Array2D[int row, int column]
For example
var test = new Array2D<RgbPixel>(10, 10);
test[0,0] = new RgbPixel
{
Red = 0,
Green = 0,
Blue = 0
};
from dlibdotnet.
Thanks. I ended up just using a Matrix instead but I appreciate the fix
from dlibdotnet.
Related Issues (20)
- create detector issue HOT 4
- Set minimum sensitivity for FrontalFaceDetector.Operator HOT 3
- Add CUDA 112 to document and publish script
- library does not depend on system libjpeg on OSX HOT 2
- How to using in .NET Core 6 HOT 1
- Extract face coordinates from upsampled image using Frontal Face Detector HOT 4
- BitmapExtensions.ToArray2D<RgbPixel>(image) throws always not supported exception HOT 4
- Rid of System.Drawing
- cuda HOT 4
- DlibDotNet.Xamarin is missing HOT 1
- ToBitmap() ambigous HOT 1
- Memory leak with Array2D HOT 2
- DlibDotNet with FaceRecognitionDotNet Not working HOT 1
- Face recognition in real time (using ar glass and unity and dlibdotnet)
- .NET 7.0 compatibility, Failed to find dll "DlibDotNetNative", for processor architecture AMD64 HOT 2
- Can't load DlibDotNetNativeDnn in Blazor WebAssembly project
- HeadPoseTraining with GPU Support possible ?
- Can't build DlibDotNet.Native.Dnn HOT 1
- External component throws an error HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dlibdotnet.