Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: sim085 on May 09, 2009, 11:05:42 AM

Title: Does workbench 3.1 ever reclaim memory back?
Post 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
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: motorollin on May 09, 2009, 11:07:45 AM
Surely it depends on whether the application in question frees its memory resources once it has finished with them.

--
moto
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: sim085 on May 09, 2009, 11:11:16 AM
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?

Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: motorollin on May 09, 2009, 11:15:27 AM
Quote
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 ;-) )

Quote
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
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: sim085 on May 09, 2009, 11:17:18 AM
Thank you very much :) That was a very quick lesson.

Regards,
Sim085
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: motorollin on May 09, 2009, 11:24:13 AM
You're welcome :-)

--
moto
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Piru on May 09, 2009, 11:25:06 AM
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
Code: [Select]
avail flush
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Rebel-CD32 on May 09, 2009, 11:27:21 AM
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.
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Rebel-CD32 on May 09, 2009, 11:47:20 AM
Ah, Piru, you beat me to it ;-)
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Karlos on May 09, 2009, 01:59:24 PM
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.
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: bloodline on May 09, 2009, 02:02:52 PM
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 :-)
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Karlos on May 09, 2009, 02:18:27 PM
Quote

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?
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: itix on May 09, 2009, 02:54:35 PM
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.
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Cass on May 09, 2009, 03:10:58 PM
@ sim085
Try PoolMem (http://aminet.net/package/util/sys/PoolMem) , or just add to the final Startup-sequence line :
Quote

LoadWB -debug

to get a "Flush" menu option ;-)

Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Piru on May 09, 2009, 03:29:04 PM
@Karlos

http://morphos-team.net/tlsf.html
Title: Re: Does workbench 3.1 ever reclaim memory back?
Post by: Karlos on May 09, 2009, 03:39:26 PM
Quote

Piru wrote:
@Karlos

http://morphos-team.net/tlsf.html


Interesting...