1.首先引入jar包 lucene-core-4.7.2.jar
<dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency>
2.java代码示例如下
for (int i = 0; i <100000; i++) { TravelAccountBillInfo info = new TravelAccountBillInfo(); billInfoList.add(info); logVoucherError(workLogsPath,"添加第"+i+"个对象,集合大小="+billInfoList.size()); logVoucherError(workLogsPath,"内存占用大小="+RamUsageEstimator.humanSizeOf(billInfoList)); }
我们这里把日志记录在一个txt里面了,这里的 humanSizeOf大小打印出来的会自动进行转换成KB,MB
标签:core,java,占用,jar,lucene,内存,apache,org From: https://www.cnblogs.com/ketoli/p/17326561.html