comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL Shapefile Object
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL Shapefile Object [message #28298 is a reply to message #28297] Thu, 29 November 2001 13:26 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Kelly Dean (krdean@lamar.colostate.edu) writes:

> I created a little procedure to plot Shapefiles with IDLffShape.
> However, it has a memory leak. Can someone point out a plug to stop my
> memory leak?
>
> The routine works great, but when I have to add graphics to 800 images,
> I run out of memory at around 500 images.
>
> A sample routine is available at ...
>
> ftp://ftp.cira.colostate.edu/Dean/teststate.pro

The problem here is that the shapefile object returns
a structure that itself has pointers in it. (This is really
the only way it can be done, because the object doesn't
really know anything about the actual shapefile you will
load.)

When this happens, you are responsible for cleaning
those pointers up yourself. Your particular test program
can clean itself up by changing these lines in the DrawSHPMap
module:


pEnts = PTR_NEW(/ALLOCATE_HEAP)
*pEnts = oShapefile->GetEntity(/ALL, /ATTRIBUTES)
;
FOR I = N_ELEMENTS(*pEnts)-1, 0, -1 DO BEGIN
PlotEnt, (*pEnts)[I], color=color
ENDFOR

To this:

pEnts = PTR_NEW(/ALLOCATE_HEAP)
*pEnts = oShapefile->GetEntity(/ALL, /ATTRIBUTES)
;
FOR I = N_ELEMENTS(*pEnts)-1, 0, -1 DO BEGIN
PlotEnt, (*pEnts)[I], color=color
Ptr_Free, ((*pEnts)[I]).vertices
Ptr_Free, ((*pEnts)[I]).measure
Ptr_Free, ((*pEnts)[I]).parts
Ptr_Free, ((*pEnts)[I]).part_types
Ptr_Free, ((*pEnts)[I]).attributes
ENDFOR
Ptr_Free, pEnts

That should do it. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Sparse matrix algorithms
Next Topic: Re: Setting history size in idlwave

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:38:37 PDT 2025

Total time taken to generate the page: 0.00523 seconds