}
@Test
public void testMemoryUsagePooled() throws IOException {
File modelDir = getModelDir();
MemoryStatus memStatus = new MemoryStatus();
memStatus.dumpMemory("before pooled model load");
//String[] names = {"person"};
//String[] names = {"date","location","money","organization","percentage","person","time"};
//<start id="ne-pool"/>
String[] names = {"person","location","date"};
NameFinderME[] finders = new NameFinderME[names.length];
for (int mi = 0; mi < names.length; mi++) { //<co id="co.opennlp.name.init4"/>
finders[mi] = new NameFinderME(
new PooledTokenNameFinderModel( //<co id="co.opennlp.name.pool"/>
new FileInputStream(
new File(modelDir, "en-ner-"
+ names[mi] + ".bin"))));
}
/*<calloutlist>
<callout arearefs="co.opennlp.name.init4"><para>Initialize name finders for identifying people, locations, and dates</para></callout>
<callout arearefs="co.opennlp.name.pool"><para>Use the string-pooling model to reduce memory footprint.</para></callout>
</calloutlist>*/
//<end id="ne-pool"/>
memStatus.dumpMemory("after pooled model load of " + Arrays.toString(names));
// ----------before pooled model load----------
// Code Cache 514.13 KBytes
// Par Eden Space 6.18 MBytes
// Par Survivor Space 0.00 Bytes