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

Home » Public Forums » archive » Re: Bug in STRMID system routine
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: Bug in STRMID system routine [message #82473] Thu, 13 December 2012 12:04
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
Hi David.

On Thu, 13 Dec 2012 12:48:04 -0700, David Fanning wrote:

> The last example, though, completely and utterly locked up
> my machine. No Task Manager, no nothing, requiring a hard
> reboot and cost me about an hour's worth of work. Not too
> excited about that. :-(
>
Sorry for that. Here I get a simple error message, that IDL is unable
to allocate memory. I would have told, if there were serious problems.

Here is the complete output:

IDL> strmid_demo
% Compiled module: STRMID_DEMO.

Starting with:
heap memory used: 728889, max: 753748, gets: 1078, frees:
238

The string needs about 10485760 bytes:
heap memory used: 11214886, max: 53158085, gets: 1083, frees:
241

A small substring needs the same amount of memory as the original
string:
heap memory used: 21707071, max: 21707071, gets: 1087, frees:
242

The memory can be released by a simple operation:
heap memory used: 11221313, max: 21707082, gets: 1088, frees:
243

The following is slow, but works:
heap memory used: 11276405, max: 21762174, gets: 3090, frees:
1243

... and this probably runs into a memory allocation error (if you
don't have tons of RAM):
% Unable to allocate memory: to duplicate string.
Not enough space
% Execution halted at: STRMID_DEMO 29
F:\home\idl\comp.lang.idl-pvwave\strmid_demo.pro
% $MAIN$
IDL>

Cheers, Heinz
Re: Bug in STRMID system routine [message #82475 is a reply to message #82473] Thu, 13 December 2012 11:48 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Heinz Stege writes:

> strmid needs a bug fix. When I start with a very long string
> a=string(byte(randomu(seed,1024^2*10)*(127.-32.))+32b)
> and then extract a short substring
> b=strmid(a,1,2)
> the result b needs 10 MB of memory. As much as the original string a.
>
> This overhead of memory can be released by a statement like b=b[0] or
> b=b+''. However this is only a workaround and should be fixed in the
> system routine itself.
>
> A demo is attached below.

I ran the demo on a Windows 7 64-bit OS with IDL 8.2.1.
It appears the bug is fixed, because the example with
a small string took a small amount of memory, rather than
the large amount you report.

The last example, though, completely and utterly locked up
my machine. No Task Manager, no nothing, requiring a hard
reboot and cost me about an hour's worth of work. Not too
excited about that. :-(

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Bug in STRMID system routine
Next Topic: array manipulation (TOTAL-ing or MEDIAN-ing) in uneven bins

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

Current Time: Wed Oct 08 18:55:39 PDT 2025

Total time taken to generate the page: 0.00530 seconds