Giter Club home page Giter Club logo

Comments (4)

xueding-e avatar xueding-e commented on July 24, 2024

这是缩减后的文件,只有10m,依旧会引起我2g jvm的oom
CoreNatureDictionary.ngram.txt

from javalambdainternals.

vincentruan avatar vincentruan commented on July 24, 2024

像是forkjoin导致内存复制的原因,建议直接输出forkjoin线程池内各内存分布看一下,应该就清楚原因了

from javalambdainternals.

xueding-e avatar xueding-e commented on July 24, 2024

像是forkjoin导致内存复制的原因,建议直接输出forkjoin线程池内各内存分布看一下,应该就清楚原因了

这样并行流不能用了哦,200倍的内存都吃完了

from javalambdainternals.

xiajiafu avatar xiajiafu commented on July 24, 2024

这样并行流不能用了哦,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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.