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

Home » Public Forums » archive » Bug in STRMID system routine
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Bug in STRMID system routine [message #82476] Thu, 13 December 2012 11:26
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
Hi all,

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.

!version={x86 Win32 Windows Microsoft Windows 8.0.1 Oct 5 2010 32 64}

Cheers, Heinz


pro strmid_demo

compile_opt defint32,strictarr,logical_predicate

print,form='(%"\nStarting with:")'
help,/mem

a=string(byte(randomu(seed,1024^2*10)*(127.-32.))+32b)
print,form='(%"\nThe string needs about %d bytes:")',$
strtrim(strlen(a),2)
help,/mem

print,form='(%"\nA small substring needs the same amount of memory '+$
'as the original string:")'
b=strmid(a,1,2)
help,/mem

print,form='(%"\nThe memory can be released by a simple operation:")'
b+=''
help,/mem

print,form='(%"\nThe following is slow, but works:")'
p=ptrarr(1000,/alloc)
for i=0,n_elements(p)-1 do *p[i]=strmid(a,i,2)+''
help,/mem

print,form='(%"\n... and this probably runs into a memory '+$
'allocation error (if you don''t have tons of RAM):")'
for i=0,n_elements(p)-1 do *p[i]=strmid(a,i,2)
help,/mem

end
[Message index]
 
Read Message
Previous Topic: Re: Select values from one array that match multiple values from an other array
Next Topic: Re: Bug in STRMID system routine

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

Current Time: Wed Oct 08 19:04:06 PDT 2025

Total time taken to generate the page: 0.00427 seconds