Memory allocated by PETSC?

Satish Balay balay at
Wed Feb 28 16:51:38 CST 2007

> Maximum memory PetscMalloc()ed 29246912 maximum size of entire process 0

The choice of wording here is a bit misleading. PETSc is using
getrusage(ru_maxrss) - which is resident set size. [so top should show
similar numbers got RSS]

This might include both code segment and data segments - and the code
segment part could be a few MB - perhaps up to 10 MB]

0: [0] 10 15321472 MatSeqAIJSetPreallocation_SeqAIJ()

This indicates that the matrix is taking approximately 15MB. And there
are other datastructures that are taking about another couple of MB

Depending upon how the malloc()/free() is implemented in the OS - some
of the freed memory might not immediately reflect on th RSS count.

Hope this helps..

On Wed, 28 Feb 2007, Shi Jin wrote:

> Hi, 
> I am curious how much extra memory PETSc allocates in
> the background. Since my estimate of memory usage of
> the code is much smaller than what I see when it runs.
> So I did this simple test:
> First I used PETSc to dump a matrix in binary format
> into a file. The file has a size of 13MB. I assume
> this should be the same size that is used to store the
> matrix in memory. Then I wrote a simple code that does
> nothing but to load this matrix from the file by
> MatLoad(). However, I found that the code consumes
> 29MB of memory (VIRT=29M from top) using single
> process. 
> This is confirmed by the -malloc_log option where it
> says
>  Maximum memory PetscMalloc()ed 29246912 maximum size
> of entire process 0
> I've attached the output of the code with detailed
> malloc information.
> Could you please explain to me about the  difference
> of  over two time?
> I don't want to criticize anything but need an clear
> idea of how much memory is needed so that I know
> whether there is a chance for me to reduce the memory
> usage of my production code.
> Thank you very much.
> Shi
> ____________________________________________________________________________________
> Need a quick answer? Get one in minutes from people who know.
> Ask your question on

More information about the petsc-users mailing list