Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: sim085 on May 09, 2009, 11:05:42 AM
-
Hi,
I noticed that when I boot in WB3.1 I have 8Mb of memory. I open some programs and this becomes 7Mb. I then close these programs however the memory remains a 7Mb!
My readings come from the top bar when booting in WB3.1
Does this mean that WB3.1 does not reclaim memory?
This happens on both ChipRAM and FastRAM.
Regards,
Sim085
-
Surely it depends on whether the application in question frees its memory resources once it has finished with them.
--
moto
-
That was fast :-) ...
I understand what you mean. This means that if a program was not written to free memory when closing then the only option was to re-start the computer in order to reclaim that memory back right!?
Also what happens when this gets to 0Mb?
-
sim085 wrote:
This means that if a program was not written to free memory when closing then the only option was to re-start the computer in order to reclaim that memory back right!?
Correct AFAIK. I wrote a slideshow application in SDL and forgot to free one of the SDL surfaces used for scaling the image. The memory footprint gradually got larger and larger and I had to just reboot (and then fix the app ;-) )
sim085 wrote:
Also what happens when this gets to 0Mb?
There's no more RAM left, so you won't be able to do anything which requires the allocation of any memory. That means you can't open any applications, any currently running applications can't do anything which requires them to use more RAM than they have currently allocated, and if some OS function requires any additional RAM then that won't work either. The precise effect of this will depend on what software/OS you are running and what you are actually trying to do.
--
moto
-
Thank you very much :) That was a very quick lesson.
Regards,
Sim085
-
You're welcome :-)
--
moto
-
This is normal. Many things (libraries, devices, fonts etc) stay in memory and the memory is only reclaimed once needed.
Obviously there also are memory leaks in applications, too.
If you really must you can try reclaiming memory manually with
avail flush
-
While some badly coded applications might leave crap in your RAM, you can usually regain all or most of this after the programs are quit by typing the simple command "Avail Flush" into a Shell/CLI window or by selecting "Execute Command" from the Workbench menu. Give it a go and see if the RAM on your screen bar goes up.
-
Ah, Piru, you beat me to it ;-)
-
A properly implemented libc should track all memory allocations made using the malloc family of operations. Similarly, a properly implememnted libc++ should do the same for anything allocated with new/new[] family of operators. Any leaks should last only as long as the application and any processes it creates remain open.
Conversely, if you use AllocMem() directly, without ever using FreeMem(), you can easily leak all your memory away, if you aren't careful.
However, not getting all the memory back that you had before launching an application isn't necessarily a leak indicator. After all, the application will open libraries and so on, which stay resident until the system is struggling to find memory for something.
-
No one here has yet mentioned Memory fragmentation... Over time the maximum size of a single allocation does down... thus you might have enough free memory (in total), but still suffer from an "out of memory" error :-)
-
bloodline wrote:
No one here has yet mentioned Memory fragmentation... Over time the maximum size of a single allocation does down... thus you might have enough free memory (in total), but still suffer from an "out of memory" error :-)
Very true, hence the "Maximum" column in your typical avail output.
I think with OS4 (and probably MOS too), a page based allocator is used. That tends to help mitigate the problem.
In fact, wasn't there a third party patch of 3.x you could install that puts big allocations at the bottom of the free memory area and small ones at the top?
-
There is TLSFmem (http://www.platon42.de/cgi-local/navbar.pl?0000&download.html#tools). From the readme (http://www.platon42.de/files/util/TLSFMem.readme):
***************************************************************************
TLSFMem is blindly fast and will reduce memory fragmentation significantly!
***************************************************************************
MorphOS 2 also implements TLSF memory allocator.
-
@ sim085
Try PoolMem (http://aminet.net/package/util/sys/PoolMem) , or just add to the final Startup-sequence line :
LoadWB -debug
to get a "Flush" menu option ;-)
-
@Karlos
http://morphos-team.net/tlsf.html
-
Piru wrote:
@Karlos
http://morphos-team.net/tlsf.html
Interesting...