# Is varinfo() designed to not report size of an array of sparse matrices?

**URL:** <https://discourse.julialang.org/t/is-varinfo-designed-to-not-report-size-of-an-array-of-sparse-matrices/53786>\
**Category:** Performance\
**Tags:** memory-allocation, sparse\
**Created:** [January 22, 2021, 3:44pm UTC](https://discourse.julialang.org/t/is-varinfo-designed-to-not-report-size-of-an-array-of-sparse-matrices/53786 "2021-01-22T15:44:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brownlight](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brownlight](https://discourse.julialang.org/u/brownlight)\
**Post date:** [January 22, 2021, 3:44pm UTC](https://discourse.julialang.org/t/is-varinfo-designed-to-not-report-size-of-an-array-of-sparse-matrices/53786/1 "2021-01-22T15:44:28Z")

</div>

Memory usage shoots up after computing two variable/references, D & Rj\_mats. For these two, varinfo() reports:

```julia
D	6.000 MiB	262144×262144 SparseMatrixCSC{Int64,Int64}
Rj_mats	10.039 KiB	256-element Array{SparseMatrixCSC{Int64,Int64},1}

```

Curios about memory usage, I saved these two in separate files as below:

```julia
@save "blah"*"_Rj_mats"*".bson" Rj_mats
@save "blah"*"_D"*".bson" D

```

The file sizes reported by OS are:  
1.44 GB (1,512,503 KB) for blah\_Rj\_mats.bson  
6.00 MB (6,145 KB) for blah\_D.bson

varinfo() was invoked after Rj\_mats is initialized inside a function as below and filled up in a subsequent loop (within the same function):

```julia
global Rj_mats = Array{SparseMatrixCSC{Int, Int}, 1}(undef,n);

```

Looking forward to comments, critique and helpful pointers.  
Thanks for reading!

---

<div class="post-metadata">

**Author:** ![dmbates](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dmbates/32/44_2.png) [@dmbates](https://discourse.julialang.org/u/dmbates)\
**Post date:** [January 22, 2021, 3:52pm UTC](https://discourse.julialang.org/t/is-varinfo-designed-to-not-report-size-of-an-array-of-sparse-matrices/53786/2 "2021-01-22T15:52:31Z")

</div>

I think you want `Base.summarysize`. As stated in `?varinfo`

```julia
The memory consumption estimate is an approximate lower bound on the size of the internal structure of the object.

```

---

<div class="post-metadata">

**Author:** ![brownlight](https://avatars.discourse-cdn.com/v4/letter/b/9d8465/32.png) [@brownlight](https://discourse.julialang.org/u/brownlight)\
**Post date:** [January 22, 2021, 4:05pm UTC](https://discourse.julialang.org/t/is-varinfo-designed-to-not-report-size-of-an-array-of-sparse-matrices/53786/3 "2021-01-22T16:05:13Z")

</div>

Thanks @dmbates for the pointer. Here is what I get:

Base.summarysize(Rj\_mats) returns 10280  
Base.summarysize(D) returns 6291624

However, following gives a more informative answer of 1548662784.

```julia
sum([Base.summarysize(Rj_mats[i]) for i in 1:length(Rj_mats)])

```

My versioninfo():

```julia
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, sandybridge)
Environment:
  JULIA_NUM_THREADS = 3

```
