Representing a 100K X 100K matrix in Java

后端 未结 9 2043
名媛妹妹
名媛妹妹 2020-12-30 13:45

How can I store a 100K X 100K matrix in Java?

I can\'t do that with a normal array declaration as it is throwing a java.lang.OutofMemoryError.

9条回答
  •  甜味超标
    2020-12-30 14:01

    100,000 x 100,000 = 10,000,000,000 (10 billion) entries. Even if you're storing single byte entries, that's still in the vicinity of 10 GB - does your machine even have that much physical memory, let alone have a will to allocate that much to a single process?

    Chances are you're going to need to look into some kind of a way to only keep part of the matrix in memory at any given time, and the rest buffered on disk.

提交回复
热议问题