Matrix{Bool}(1000000, 1000000) really?

Is it possible to create such a matrix?

Matrix{Bool}(1000000, 1000000)

In this form, I certainly get OutOfMemoryError()
Maybe there are some kind of special matrix, I need to create an empty matrix 1000000x1000000, after entering the values.
M[234893, 435345] = 1

Depending on sparsity, consider sparse arrays or BitArrays.


Just check what your libc / OS / machine handles. E.g. on my machine (linux with gnu libc), it looks like I don’t get single allocs that exceed phys+swap size.

I think that limitation is due to glibc malloc rather than the linux kernel, so you can probably work around it. But do you really need a matrix that doesn’t fit into phys+swap? OOM killer will terminate you when you write to it, and zeros can be obtained faster.

julia> p = ccall(:malloc, Ptr{Nothing}, (Csize_t,) ,10^11)
Ptr{Nothing} @0x0000000000000000

julia> p = ccall(:malloc, Ptr{Nothing}, (Csize_t,) ,10^10)
Ptr{Nothing} @0x00007f2d23f41010
1 Like