Re: memory leak when using png driver?

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Fri Feb 05 2010 - 16:29:41 MST

Hi Cathy,

I'm not totally sure about a memory leak offhand, but I might suggest
that you pull the code that sets up resources and opens the
workstation to outside of your loop-through-days.

Hope that helps...
Rick

On Feb 5, 2010, at 4:23 PM, Cathy Smith wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> NCL users,
>
> I have code that loops through a file to create a set of maps for a
> year. I open the file and get the variable plotted before the loop to
> plot the maps.
>
> e.g.
>
> read data
>
> do loop though days
> wks_type = "png"
> rez=2560
> output="png"
> temp = pr_wtr(day,:,:)
> wks = gsn_open_wks(output,name) ; open a png file
> gsn_define_colormap(wks,"prwtr") ; choose colormap
> ...set plot parameters...
> plot=gsn_csm_contour_map_ce(wks,temp,res)
>
> end do
>
> The problem is that the code isn't releasing memory and it starts
> taking
> over all the memory in the machine (30G!). Is there a way to release
> the
> memory? Or, do I likely have an error somewhere? We are using NCL
> 5.1.1
> on a 64 bit Linux redhat machine (V 2.6.18-164.6.1.el5)
>
> Thanks
> Cathy Smith
>
>
>
>
> (short code that produces error)
>
> ;************************************************
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ;************************************************
> begin
>
> ;************************************************
> ; read in netCDF file
> ;************************************************
> a = addfile("/Datasets/20thC_ReanV2/monolevel/pr_wtr.eatm.
> 1902.nc","r")
> pr_wtr = short2flt( a->pr_wtr )
>
> do id=0,364*4
> nd=id+1
> temp = pr_wtr(id,:,:)
> name1=sprinti("%4.4i", nd)
> name="/scratch60d/csmith/20th/prcpx." + name1
> print(name)
> rez=2560
> output="png"
> output@wkWidth = rez ; must be square; deviations
> output@wkHeight = rez ; either way are wasted
> wks = gsn_open_wks(output,name) ; open a png file
> gsn_define_colormap(wks,"prwtr") ; choose colormap
>
> res = True
> res@cnFillOn = True ; turn on color fill
> res@gsnSpreadColors = True ; use full range of color map
> res@mpMinLonF=0
> res@mpMaxLonF=360
> res@gsnAddCyclic=True
> res@mpMinLatF = -90
> res@mpMaxLatF = 90
>
> plot=gsn_csm_contour_map_ce(wks,temp,res) ; now draw as
> one plot
>
> end do
> end
>
> )
>
>
> - --
> NOAA/ESRL PSD and CIRES CDC
> 303-497-6263
> http://www.esrl.noaa.gov/psd/people/cathy.smith/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (Darwin)
>
> iEYEARECAAYFAktsqF4ACgkQFiO7KzMhjUST4gCfWqAgknO2by0/Qpz7zoSIbw4/
> yAUAn3hq+7TbH7okBqUW1QjSGkko04G6
> =LNms
> -----END PGP SIGNATURE-----
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Feb 5 16:29:47 2010

This archive was generated by hypermail 2.1.8 : Sun Feb 07 2010 - 15:37:25 MST