JFastText icon indicating copy to clipboard operation
JFastText copied to clipboard

the problem with model replace

Open Trangle opened this issue 8 years ago • 3 comments
trafficstars

I wrote my code like JFastText jft = new JFastText(); jft.loadModel(MODEL_FILE); int cnt = 0; while(true) { System.out.println("new: " + (++cnt)); JFastText after = new JFastText(); after.loadModel(MODEL_FILE); JFastText before = jft; jft = after; // after = null; System.out.println("done"); before.unloadModel(); // before = null; System.gc(); }

then this process will exit with error by null pointer deallocate, is there any resolution to this case? Thank you.

Trangle avatar Oct 16 '17 11:10 Trangle

@vinhkhuc

Trangle avatar Oct 16 '17 15:10 Trangle

Hi @Trangle, Your code seem to swap two models, so that I think you should try to swap model_file, which is a path to your model file, instead of exchange model variables.

villahp avatar Oct 24 '17 02:10 villahp

@villahp Yes, I need to swap two models to make the first model still work while the new model is loading. The problem is that when encountered java gc, in the process of memory release, the object with no memory malloc will be released because the destructor in fb c++ version. I solved the problem by relpace the c++ version of fasttext to the newest one, which add size judge in ~QMatrix.

Trangle avatar Oct 25 '17 06:10 Trangle