在系统上运行斯坦福·科伦普(Stanford Corenlp)时,似乎并没有清空内存。即使使用线程...
我有2个类 testx.java (包含主线程)& testx2.java 实现运行。
我想做的是在字符串号上运行斯坦福·科伦普(Stanford Corenlp)之后,完全清空内存。1如下所示...
我知道可以做到!因为我之前已经看到内存使用率下降了(但我没有保留该代码!:/)
VM参数为-XMX2048M
public class Testx {
public static void main(String[] args) {
String text = "If you had to guess the top city for entertainment & media your first thought would probably be LA.";
Textx2 x = new Textx2(text);
Thread t1 = new Thread(x);
t1.run();
t1.interrupt();
t1 后的内存使用率已完成
//在转到下一个字符串之前,如何在此处完全清空内存?
String text2 = "Taylor Swift has a certain attachment to the number 1989 it's the year of her birth.";
Textx2 x2 = new Textx2(text2);
Thread t2 = new Thread(x2);
t2.run();
t2.interrupt();
}
testx2.java代码。
String text;
public Textx2(String text) {
this.text = text;
}
@Override
public void run() {
Properties props = new Properties();
Annotation document = new Annotation(text);
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, depparse, sentiment, mention, dcoref, natlog, relation, entitymentions, openie");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
pipeline.annotate(document);
}
Java内存使用
两个线程完成后尝试运行此行:
StanfordCoreNLP.clearAnnotatorPool();