Comments (4)
这是缩减后的文件,只有10m,依旧会引起我2g jvm的oom
CoreNatureDictionary.ngram.txt
from javalambdainternals.
像是forkjoin导致内存复制的原因,建议直接输出forkjoin线程池内各内存分布看一下,应该就清楚原因了
from javalambdainternals.
像是forkjoin导致内存复制的原因,建议直接输出forkjoin线程池内各内存分布看一下,应该就清楚原因了
这样并行流不能用了哦,200倍的内存都吃完了
from javalambdainternals.
这样并行流不能用了哦,200倍的内存都吃完了
通过运行你的代码,我这边(jdk版本是1.8.0_144)设置的jvm参数:-Xmx1024m -Xms1024m,发现是能运行成功得出结果的,多次运行平均耗时5000~6000ms,但是串行流的时间只有它的十分之一。按照我的理解,并行流的使用场景是CPU密集型的,你这个场景应该是不太适用。测试代码如下:
public static void main(String[] args) { long uniqueWord; Path path = Paths.get("C:\\Users\\DELL\\Downloads\\CoreNatureDictionary.ngram.txt"); try (Stream<String> lines = Files.lines(path, Charset.defaultCharset())) { long start = System.currentTimeMillis(); uniqueWord = lines.flatMap(line -> Arrays.stream(line.split(" "))).parallel().distinct().count(); // uniqueWord = lines.flatMap(line -> Arrays.stream(line.split(" "))).distinct().count(); System.out.println(uniqueWord); long end = System.currentTimeMillis(); System.out.println("耗时" + (end - start) + "ms"); } catch (IOException e) { e.printStackTrace(); } }
from javalambdainternals.
Related Issues (6)
- 第7篇什么时候出 HOT 4
- 请教下sink之间是倒序查找的,那么如何保证执行操作的正确性? HOT 1
- 疑问 HOT 1
- 疑问 HOT 2
- 关于sink设计的一个小疑问 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javalambdainternals.