[petsc-dev] [petsc-maint] Potential BUG for petsc4py

Matthew Knepley knepley at gmail.com
Tue Nov 8 07:42:58 CST 2016


On Tue, Nov 8, 2016 at 2:19 AM, Ji Zhang <gotofd at gmail.com> wrote:

> Dear all,
>
> I'm a petsc and petsc4py user. Obviously, the package is outstanding and
> elegant for those projects involving large matrix calculation. One small
> defect, I think, is that petsc4py.PETSc.Object.destroy() method do not
> work in parallel mode. The memory cannot be released.
>
> For example, if I create a Mat obj named mat1, do some stuffs, and then
> use mat1.destroy(), the memory useage of the code decreased without mpirun,
> what is not change with mpirun.
>

This is about how the operating system is dealing with memory. PETSc calls
free(), but that does not mean that the OS
decreases the memory unfortunately. However, it should normally be
reclaimed if you try and reallocate.


> More, let mat2=mat1, after do mat1.destroy(), mat2 is unacceptable whether
> memory is released or not.
>

Here you are making a shallow copy, meaning only the pointer to the object.
Thus when mat1 is destroyed, so is mat2.
If you want a real copy, you need to use MatDuplicate().

  Thanks,

     Matt


> Is there any one can check if I made some mistakes? Thanks.
>
> 此致
>     敬礼
> 张骥(博士研究生)
> 北京计算科学研究中心
> 北京市海淀区西北旺东路10号院东区9号楼 (100193)
>
> Best,
> Regards,
> Zhang Ji, PhD student
> Beijing Computational Science Research Center
> Zhongguancun Software Park II, No. 10 Dongbeiwang West Road, Haidian
> District, Beijing 100193, China
>



-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20161108/3eb2660c/attachment.html>


More information about the petsc-dev mailing list