it has something to do with memory in use. I just noticed that whenever (Hollywood or AMIGA OS3.1) frees some memory the program execution slows down (from average 8 seconds to 12 or even 20 seconds sometimes).At first I was looking for some mistakes in my script but then I noticed memory amount on the workbench's menu and I'm almost 100% sure that must be the problem.

The program is just an infinite loop (for testing), after every loop it prints out the time how long the calculations took time.EVERY first run is always the fastest (~8seconds), each other is much slower (~13 seconds or even more, sometime less).When the program starts I can see that free memory is going down - the loop is finished and the execution time is fine. When the program runs another loop I can see that free memory is going down again but sometimes it stops (not changing) and thet it jumps up (shows more free memory that before) - when that happens my program slows down.

How to avoid this? Or How can I force to free memory when the program is iddle - I tried Garbage collector but no luck.

Sorry for the late reply.I've been away from amiga for a month already - once I get back to it I'll check couple of ideas that came to my mind and if everything fails then I'll post some examples.Thank you.

StartTimer(0) For Local i=0 To 279 InsertItem(tbl,i) tbl[i]={a={1,0,1,0,0,0,1,0,1}} Line(0,10,i*46/279,10,color) Next TextOut(20,20+q*8,GetTimer(0)\1000)

ResetTimer(0) For i In IPairs(tbl) tbl[i].b={}

CreateBrush(i,16,16) SelectBrush(i) If tbl[i].a[0] Then x=0 Else InsertItem(tbl[i].b,{0,0}) If tbl[i].a[1] Then x=0 Else InsertItem(tbl[i].b,{1,1}) If tbl[i].a[2] Then x=0 Else InsertItem(tbl[i].b,{2,2}) If tbl[i].a[3] Then x=0 Else InsertItem(tbl[i].b,{3,3}) If tbl[i].a[5] Then x=0 Else InsertItem(tbl[i].b,{5,5}) If tbl[i].a[6] Then x=0 Else InsertItem(tbl[i].b,{6,6}) If tbl[i].a[7] Then x=0 Else InsertItem(tbl[i].b,{7,7}) If tbl[i].a[8] Then x=0 Else InsertItem(tbl[i].b,{8,8}) EndSelect Line(60,10,60+i*46/279,10,color) Next TextOut(80,20+q*8,GetTimer(0)\1000)Next

TextOut(#RIGHT,#BOTTOM,"press a key")WaitKeyDown("any")

There are 2 steps:- first one is making a table- second one is making a brushes along with some if's

THE MOST IMPORTANT: slow down occurs when the ELSE-part has something to do with a tableInsertItem(tbl[i].b,{0,0}) makes it the worst. Below you can se the results from above script (the numbers mean seconds for 1st step and 2nd step):

2 - 52 - 52 - 132 - 112 - 54 - 104 - 92 - 152 - 142 - 13

I run this few times and 5 times in a row I got EXACTLY the same results.

when I change ELSE part a little eg: InsertItem(tbl[i].b,{0}) - the slow downs are smaller

when I do this: tbl[i].b=0 , the results look like this:

2 - 32 - 33 - 32 - 42 - 32 - 33 - 32 - 33 - 32 - 3

I'm not a programmer so maybe that behavior is quite normal - if so, then sorry for making problems out of nothing

that script is doing the same routine 10 times - the listings with the times i gave are showing how many seconds took the first part and the second one. Then the whole procedure is repeated and new times are printed below (up to 10 lines).Talking about "slow downs" I mean that each repetition should be done within more or less the same time (like the last listing) - in the example above you can see that is not always true.In my real program that "slow downs" are PITA since the times I'm talking about can grow up to even 50 seconds ( where first run is usually around 11 seconds)

InsertItem() is slow because it always calculates the number of elements in the table in order to check whether the position you passed is invalid. So in performance-critical applications where you only need to append an element to a list, doing this manually will be a lot faster than InsertItem().

Anyway when I changed all insertItem() in the test script above to tbl[listItem(tbl)] it didn't change a thing. The program still runs like before (same results).And that is something I cannot understand - that script repeats the same procedure 10 times - every time it erases the main (and the only one) table and just does the same things (creates brushes and runs some if's). And every (ok, not every time) it gives different times. As you can see here (each line represents another run, from 1st to 10th):

2 - 52 - 52 - 132 - 112 - 54 - 104 - 92 - 152 - 142 - 13

since everytime the same commands are being executed and the same numbers of time I belive it should give same duration (and I assume that 2sec and 5 sec are the correct ones )

The other strange thing (at least for me) is why every time I run the script (10 repetitions) I get EXACTLY the same results.Please note I am talking about test done on real a1200 with blizzard 030 (not PC emulator).