Replies: 2 comments 1 reply
-
@csxiang18 Your code will cause memory leak, the predictor should be closed explicitly:
But Predictor creation may has it's own cost (depends on engine, MXNet engine has minimal cost of creating new Predictor). We recommend you to create a Predictor per thread, or use Object pool. The easiest way (not cleanest way) is to use ThreadLocal. |
Beta Was this translation helpful? Give feedback.
-
The easiest way is:
|
Beta Was this translation helpful? Give feedback.
-
Hi, I have a quick question about the multi-thread inference.
I have a tomcat server to provide the dnn prediction service. And I packaged the model like this:
Each tomcat thread will use
dnnService.predict(features);
. Will this cause any performance or GC issues? Or is this the correct way to use? I see from the doc that for each thread, we should use anewPredictor
. But when I use this like this way, I see that the memory seems to increase a lot.Beta Was this translation helpful? Give feedback.
All reactions