Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.
Memory leak in SRP List GetAt ?
I've just been doing some benchmarking to see whether it's faster to use SRP_List_GetAt(), or OI's BRemove statement, to sequentially parse a list. I used this code:
declare function timegettime, srp_list_create, srp_list_getat
tot = 9999999
* Construct a sequential list
call rti_stringbuilder( h, 'New', tot*10)
for i = 1 to tot
call rti_stringbuilder( h, 'Append', i: @fm)
next i
call rti_stringbuilder( h, 'ToString', list, 1)
call rti_stringbuilder( h, 'Destroy')
* Access the list sequentially
Call Send_dyn( "Start Test")
startTime = timegettime()
p=1
h = srp_list_create( list, @fm)
for i = 1 to tot
k = srp_list_getat( h, i)
*Bremove k from list at p setting d
next i
call srp_list_release( h)
retVal = timegettime() - startTime
Call Send_dyn( retVal)
Return retVal
OpenInsight crashed during the process using SRP_List_GetAt(). I could see in Task Manager that memory usage on the OINSIGHT.EXE process just kept increasing during the test loop before that happened. This is using SRPutilities v1.4.8 on OI 9.4.
BTW, BRemove is lightning fast!, at least compared to constructing the list initially.
Cheers, M@
Comments
Yes, it is crashing with "OpenInsight has stopped working". Actually - it seems to happen in SRP_List_Create()! It doesn't even get to the loop.
From the Event Viewer:
HTH, M@
Also, since this was brought about by benchmarking, I want to mention another reason why BRemove is so much faster the SRP List for sequential reading. SRP Lists are indexed so that Locates are blazing fast. Indexing takes time, however. So, the rule of thumb is: if you are going to access elements in sequential order, use BASIC+, but if you are going to access elements in no particular order, use SRP Lists.
Cheers, M@