When an executable takes memory from the OS, it seldom gives it back. What this means, is that if you run:
from dolfin import *
import resource
def print_memuse():
print str(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) + " kb"
def make_mesh():
print_memuse()
mesh = UnitSquareMesh(1000,1000)
print_memuse()
mesh = Mesh(mesh)
print_memuse()
make_mesh()
make_mesh()
make_mesh()
make_mesh()
print_memuse()
You will see:
96664 kb
169936 kb
240336 kb
240336 kb
240336 kb
240356 kb
240356 kb
240356 kb
240356 kb
240356 kb
240356 kb
240356 kb
240356 kb
so the system memory usage stays at the maximum it ever reached.
In summary, the memory from a deallocated mesh is released to the program, but not to the OS.