Speed up a slow loop
J. Landman Gay
jacque at hyperactivesw.com
Tue Mar 8 14:28:51 EST 2022
On 3/8/22 10:30 AM, Alex Tweedly via use-livecode wrote:
> I guess I'm not convinced about VM space thrashing being the problem, certainly not due to the
> wordlist. It's 2.5 Mb - i.e. 0.02% of the real RAM in a Pixel 5. There may be something else in
> the app making the total VM space very large - but the wordlist wouldn't do it on its own.
I'm not sure either. A few days ago I did some tests trying to track the total amount of RAM
that was used by looking at the memory stats in the developer options. I started the game, did
some quick word lookups, quit and removed from memory, then checked usage. It isn't very
specific but while my app was running the Pixel 6 had a maximum usage of 368MB after three
tests, and the Pixel 5 maxed at 255MB. This isn't near the top of the list, other apps use more.
On the Pixel 5 today, with only background apps running, I'm using 55% of RAM which leaves
3.5GB free. The Pixel 6 is using 70% with 2.4GB free. The OS on the 6 is bigger and I have more
background processes running there.
In trying to reduce the memory footprint I wanted to see how much RAM my script locals were
storing. The easiest way was to get the value of all of them, write them consecutively to a
file, and let Finder tell me the size. I found that Alex's brilliant script was holding 5MB of
data that I didn't need, so I emptied out the variables that were only used to calculate the
board and kept the single one I needed for lookups. That file was 3K.
I need to test more today. Last night I thought I was all set, got a great board and quickly
found 125 words. Everything was snappy and worked great. Then suddenly the app froze solid,
nothing responded, and I had to quit to the launcher. Which was a shame because it was a really
good board. That was before I wiped out the extra 5MB of unnecessary variable data, and there
may be more I can do trim it down. But you'd think 2-3GB of free RAM could accomodate it.
If I can't figure it out soon, I'll give it to all of you to see if you can.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode