Memory allocated by PETSC?

Barry Smith bsmith at
Wed Feb 28 16:59:51 CST 2007


    The current algorithm used to do a MatLoad_MPIAIJ requires 
memory on each process of about TWICE the memory required just for
the matrix. For example, if a matrix requires 40 megabytes total,
after it is completely loaded on 4 processes it will take about 
10 megabytes on each process, BUT during MatLoad each process will
use 20 megabytes (10 for the final matrix and 10 for work space
to receive message in). This is why the total is 29 meg: 15meg for the final
matrix and around 18meg for the MatLoad.


We could work hard and reduce the amount of memory used during the
load process if this is problem for you. We are not fans of loading
huge matrices from files so generally this is not a problem.

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