No free memory in module area
Alan Adams (2486) 1149 posts |
I’m running RO 5.28 on a pi3B. I have one program running, and until reently it’s been running for several months without a stop or machine restart. Now however, after a few hours it quite, and any attempt to do anything, such as open a menu or a filer window gets a message similar to “no free memory in module area”, of “insufficuent memory to open menu”. When the computer starts up, before running my program, the memory display shows the module area has 47K free, and largest block 27K. This seems a bit low. So the two questions are: why is this happening? and how do I increase the initial module area size on restart? I can drag the slider to increase it, but that’s a manual action. |
Stuart Painting (5389) 714 posts |
This sounds like you’ve run out of free memory altogether, rather than it just being a problem with the module area on its own.
That is normal. The module area is typically only as big as it needs to be, and will grow if necessary. There is an upper limit, but I’ve forgotten what it is. My guess is that there’s a memory leak somewhere. Check the “System memory allocation” section of the Tasks window when your program has started up, and again after it has been running for a while. |
Alan Adams (2486) 1149 posts |
Here’s what the memory display looks like after a restart and before running Templogger. After ten minutes running, the only change seems to be an increase in the size of the module area. What could cause that? And why is it doing it now, when it wasn’t doing it a week ago, when I haven’t changed anything in between? Does the module area possibly have a 28MB limit? It’s starting at around 13MB. |
Rick Murray (539) 13840 posts |
Applications are limited to 28MB if you’re running Aemulor. The RMA is normally limited to 256MB. Can you do a screenshot when it fails so we can see where the memory is getting allocated.
Absolutely nothing? No OS or firmware update, no software update, no tweaking settings? |
Stuart Painting (5389) 714 posts |
Assuming that nothing you are doing would cause additional modules to be loaded, I can think of two reasons for the RMA to get larger:
It needn’t have been a change to the program or the OS. For example, the file(s) you are working with could have been getting steadily larger and may now have exceeded some limit. |
Alan Adams (2486) 1149 posts |
Once it fails, nothing works. Anything that would open a menu for example fails with something like “insufficient memory”.
The program adds to a log file every 10 minutes, creating the file if it doesn’t already exist. It also does a Settype on the file after closing it each time. After the last failure and restart, the logfile was around 150MB in size. I’ve since deleted it. The SD card has approx 1.4GB of free space. If deleting that file hasn’t changed things, then I’d expect it to have failed by tomorrow morning. I now have a Reporter window open on screen, so I’m hoping there might be something in that. The tasks window is also on screen. I will be restricted to what is on screen at the time as nothing I do works at that point. I should probably have said, that when this has occurred, I come back to the computer, and the program window is no longer there. There is no error display – nothing to indicate the problem except that the program has gone. |
Martin Avison (27) 1494 posts |
As you are running Reporter, the *ReportHeap command will give you statistics of the RMA usage, eg |
Rick Murray (539) 13840 posts |
Leave the memory allocation window open. When it fails, press F12 then enter |
Stuart Swales (8827) 1357 posts |
I was mildly shocked to see my ARMX6 had an RMA of 2.7MB after booting and setting up DDE for use. If it were 13MB I’d be calling for the nurse! |
Rick Murray (539) 13840 posts |
Just checked mine. Booted, loaded the DDE, Zap, new stack, and all the usual rubbish, plus NetSurf, and my BBS server, and a program that reads the current weather every five minutes. The RMA is 5856K. RISC OS 5.29 (15-Jul-21; oh, how I wish it would use a full month name and four digit year). System uptime is 3 days, 0 hours, 53 minutes, and 49 seconds (as I write this). I find the rapidly growing RMA of the OP to be… concerning. |
Rick Murray (539) 13840 posts |
<drops a load of source into Zap> Hmm… F12 is caught by Switcher that does a Wimp_StartTask “ShellCLI”. There’s a lot of faffing with handlers, and allocating new application memory. So far nothing obviously touches the RMA, but something like OS_ReadLine or OS_CLI could bearing in mind there’s all sorts of things like messing with the VDU drivers, redirections, GSTrans, and so on going on in the background. Oh, no… It looks like ScreenSave creates a temporary sprite header in VDU workspace, but it also needs to allocate some memory in the RMA large enough to handle a scanline’s worth of pixel data. Well, it might work, but it equally might blow up. I’d say, try it, see what happens. |
Alan Adams (2486) 1149 posts |
It’s not growing now. The first few minutes of running Templogger it jumped to 13616K, and it’s still there a couple of hours later. The program doesn’t make any RMA allocations – the only connection is Socketwatch. Reportheap gives Heap RMA=&20000000 Max=256M Size=13616K Free=91K Largest=28588 Used=13524K (1562) Freed=65120 (117) Unused=28592
If it fails again, I will. |
Chris Mahoney (1684) 2165 posts |
Perhaps take a photo of the screen first, so that you at least have something. |
Jon Abbott (1421) 2651 posts |
It sounds like Templogger is doing something that’s leaking RMA space, probably a temp RMA allocation that isn’t being freed. |
Alan Adams (2486) 1149 posts |
Templogger is written entirely in BASIC. It makes no use of RMA (except that it uses the Socketwatch module, which in turn allocates a small block of RMA for its own use). It’s now been running for over 24 hours and in that time the module area size has not changed. The only thing that I am aware of changing between the regular failures and now, is that I deleted the log file it was creating (and several old copies), forcing it to create a new one. AS I recall the log file at that point was about 135MB in size. After the deletes the free space on the SD card is around 1.4GB. I can’t be absolutely sure that the SD card had not run out of free space, but I can’t see how that could have caused such a drastic cessation of activity from the OS. There have been comments that the initial size of the module area is unusually large. I cannot account for that. I’ve checked immediately after a cold start and it is already large then, before I’ve started any user applications. I had a look through the verbose listing of the area produced by Reporter. I was hoping to see a pattern, but the only thing that seemed at all repetitive was a series of “32 bytes allocated” followed by “64 bytes deallocated”. That should decrease the usage, not increase it? No indication of WHAT was doing that. |
Rick Murray (539) 13840 posts |
Can you drop here the results of the following two commands: *Modules *Status This should show what is being loaded into the RMA, and what your system configuration is (just in case it’s simply a weird configuration). |
Martin Avison (27) 1494 posts |
I am away from home & RISC OS at the moment, but a few comments…
|
Jon Abbott (1421) 2651 posts |
The 32/64 byte blocks will most likely be the Wimp, as I noted a few years back the Wimp is a major contributor to RMA fragmentation and should probably be using its own private heap for temporary allocations. |
Frank de Bruijn (160) 228 posts |
16K blocks. In any version before 0.05. Claimed, never used, never released. I can’t remember the frequency either. |
Rick Murray (539) 13840 posts |
A side effect of the legacy, for back in the day it was just easier to grab a bit of the RMA if one wanted “managed” (as in, an existing heap structure) memory that was certain to not be paged out. What made sense in Arthur/RISC OS 2 doesn’t make so much sense these days. Lucky as machines got faster, memory got larger, which basically papered over the issues. I’m aware of the horrible because I rummaged around in the Wimp to answer questions like “where are window definitions actually put?”. But… Menus generated on the fly. Mode blocks for changing mode. Icon blocks. Pixtrans/colour tables. Template loading… Pretty much any time the Wimp needs some workspace, it reaches into the RMA. |
Alan Adams (2486) 1149 posts |
In fact in this case it turns out I’m not using it. Many of my current programs do, but not this one.
It’s set to 10MB – that is the answer then.
|