FaceRecognitionDotNet icon indicating copy to clipboard operation
FaceRecognitionDotNet copied to clipboard

FrontalFaceDetector cause MemoryCorruptionException in multithread usage

Open matteofabbri opened this issue 2 years ago • 4 comments

  • implement a code that find face
  • invoke the code with a big bunch of different threads
  • Fatal MemoryCorruptionExecption, process die and there is no way to recover

matteofabbri avatar Apr 04 '22 09:04 matteofabbri

@matteofabbri You can not share FRDN instance between threads. So you must

  • Create some FaceRecognition instance
  • Use multiprocess

takuya-takeuchi avatar Apr 05 '22 03:04 takuya-takeuchi

@takuya-takeuchi if you take a look at my PR i fixed the issue. Making different issues dont fix the problem, due to DlibDotNet internal issues. ASAP i will fix other not thredsafe components

matteofabbri avatar Apr 06 '22 12:04 matteofabbri

You may be able to avoid excpetion for FaceLocation but other function may face to same issue. Should we generate internal instance when function is invoked every time? I guess it is not good.

takuya-takeuchi avatar Apr 08 '22 00:04 takuya-takeuchi

In the path of detecting faces, extracting encodings and recognize a subject in those encoding there are no other thread unsafe regions. Unless you select a different kind of faceselector that i will try to fix asap. On the test i runned, the whole path takes more that 24seconds for serving a thread using the lock to access the FRDN and 400ms with the fix that i applied

matteofabbri avatar Apr 09 '22 09:04 matteofabbri