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

Home » Public Forums » archive » Re: IDL doesn't close files.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: IDL doesn't close files. [message #38977] Fri, 16 April 2004 11:33
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Ed Meinel" <meinel@aero.org> wrote in message news:63342373.0404160645.cb35f69@posting.google.com...

> Yes, I have the same problem. It happens to me when I open and
> (supposedly) close a lot of image files during a long session. After a
> while, IDL refuses to open any more files, claiming that it has run
> out of LUNs. I've tried CLOSE, FREE_LUN, /FORCE, all to no avail. The
> only solution I have found is to restart IDL. Any other ideas?
>
> Ed
>
> PS. This happens with 5.6 on a Mac and Sun and also with 6.0 on a Sun.

Hi Ed,
this does sound like the problem I've seen before.
Can you post a small snippet of code that demonstrates the error?

Cheers,
bob
Re: IDL doesn't close files. [message #38979 is a reply to message #38977] Fri, 16 April 2004 07:45 Go to previous message
meinel is currently offline  meinel
Messages: 14
Registered: February 1994
Junior Member
Craig Markwardt <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:<on1xmo60qo.fsf@cow.physics.wisc.edu>...
> "R.G. Stockwell" <noemail@please.com> writes:
>>
>> Do NOT close then use free_lun.
>> If you used a get_lun, then use free_lun.
>> i.e.
>
> Bob, I don't by your suggestion. CLOSE closes a file, and FREE_LUN
> deallocates a unit number; they are completely separate functions. [
> Although it is true that FREE_LUN on an open unit will close it as
> well as deallocating it. ] You can definitely use CLOSE and then
> FREE_LUN. I do it all the time.
>
> Craig

Yes, I have the same problem. It happens to me when I open and
(supposedly) close a lot of image files during a long session. After a
while, IDL refuses to open any more files, claiming that it has run
out of LUNs. I've tried CLOSE, FREE_LUN, /FORCE, all to no avail. The
only solution I have found is to restart IDL. Any other ideas?

Ed

PS. This happens with 5.6 on a Mac and Sun and also with 6.0 on a Sun.
Re: IDL doesn't close files. [message #38980 is a reply to message #38979] Fri, 16 April 2004 07:19 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
"Craig Markwardt" <craigmnet@REMOVEcow.physics.wisc.edu> wrote in message news:on1xmo60qo.fsf@cow.physics.wisc.edu...
>
> "R.G. Stockwell" <noemail@please.com> writes:
>>
>> Do NOT close then use free_lun.
>> If you used a get_lun, then use free_lun.
>> i.e.
>
> Bob, I don't by your suggestion. CLOSE closes a file, and FREE_LUN
> deallocates a unit number; they are completely separate functions. [
> Although it is true that FREE_LUN on an open unit will close it as
> well as deallocating it. ] You can definitely use CLOSE and then
> FREE_LUN. I do it all the time.
>
> Craig

Hi Craig,
yes, I should have said "do not get_lun and then close", that was the
problem that I had in mind when I read the OP. I had a colleague
ask me about that type of problem a short while ago, so I had it
in mind. It appears that closing then free_luning does not cause
the memory leak.


-bob
Re: IDL doesn't close files. [message #38984 is a reply to message #38980] Fri, 16 April 2004 02:15 Go to previous message
justspam03 is currently offline  justspam03
Messages: 36
Registered: October 2003
Member
Hi,

I had a similar problem when using the XMLparser, say:

catch, error_status
if( error_status ne 0 ) then begin
catch, /cancel
help, /last_message
close, /all, /force
return, 0
end

xmlparser = obj_new('SUBCLASS_TO_IDLffXMLSAX')
xmlparser->parsefile, 'somefile'
obj_destroy, xmlparser
return, 1

How can I close the file when the XML parser fails?
The code suggested above does not work under Win2000 - the
file is still blocked afterwards (which is pretty bad,
because I'd like to create valid default file in this case).

Any suggestions?
Cheers
Oliver
Re: IDL doesn't close files. [message #38985 is a reply to message #38984] Thu, 15 April 2004 20:49 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"R.G. Stockwell" <noemail@please.com> writes:
>
> Do NOT close then use free_lun.
> If you used a get_lun, then use free_lun.
> i.e.

Bob, I don't by your suggestion. CLOSE closes a file, and FREE_LUN
deallocates a unit number; they are completely separate functions. [
Although it is true that FREE_LUN on an open unit will close it as
well as deallocating it. ] You can definitely use CLOSE and then
FREE_LUN. I do it all the time.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: IDL doesn't close files. [message #38987 is a reply to message #38985] Thu, 15 April 2004 16:07 Go to previous message
R.G. Stockwell is currently offline  R.G. Stockwell
Messages: 363
Registered: July 1999
Senior Member
> wl wrote:
>> I create a text file in IDL using openw, write some text to it, then
>> close it using
>> close, u, /force
>> free_lun, u, /force
>>
>> Then, when I try to open it in a text editor (I use the FAR manager's
>> internal editor) it says that is unable to open it because of sharing
>> violation.
>>
>> What should I do to close just created file without exiting IDL?


Do NOT close then use free_lun.
If you used a get_lun, then use free_lun.
i.e.


OPENW, U, 'file.dat', /GET_LUN
writeu,U, 1.0
free_lun,U



That is what is causing your leak (probably).

Cheers,
bob
Re: IDL doesn't close files. [message #38989 is a reply to message #38987] Thu, 15 April 2004 14:57 Go to previous message
Mark Hadfield is currently offline  Mark Hadfield
Messages: 783
Registered: May 1995
Senior Member
wl wrote:
> I create a text file in IDL using openw, write some text to it, then
> close it using
> close, u, /force
> free_lun, u, /force
>
> Then, when I try to open it in a text editor (I use the FAR manager's
> internal editor) it says that is unable to open it because of sharing
> violation.
>
> What should I do to close just created file without exiting IDL?

It *should* work.

It's not normally necessary to use /FORCE. What happens when you omit it?

Also, it's not normally necessary to use CLOSE. FREE_LUN on its own
should close the file if necessary, before freeing the unit number. (But
using CLOSE shouldn't cause a problem.)

Have you made some more elementary mistake, like passing an incorrect
unit number? For example, the following would leave file1 opened:

openw, u, file1, /GET_LUN
openw, u, file2, /GET_LUN
...write some stuff
free_lun, u
free_lun, u

What happens when you try CLOSE, /ALL?


--
Mark Hadfield "Ka puwaha te tai nei, Hoea tatou"
m.hadfield@niwa.co.nz
National Institute for Water and Atmospheric Research (NIWA)
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Transparent polygons
Next Topic: need to develop interactive plot routine

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

Current Time: Wed Oct 08 15:39:17 PDT 2025

Total time taken to generate the page: 0.00577 seconds