Welcome, Guest. Please login or register.

Author Topic: Does workbench 3.1 ever reclaim memory back?  (Read 2858 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show only replies by sim085
Does workbench 3.1 ever reclaim memory back?
« 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
 

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #1 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
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show only replies by sim085
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #2 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?

 

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #3 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
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline sim085Topic starter

  • Hero Member
  • *****
  • Join Date: Aug 2008
  • Posts: 958
    • Show only replies by sim085
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #4 on: May 09, 2009, 11:17:18 AM »
Thank you very much :) That was a very quick lesson.

Regards,
Sim085
 

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #5 on: May 09, 2009, 11:24:13 AM »
You're welcome :-)

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #6 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
 

Offline Rebel-CD32

  • Sr. Member
  • ****
  • Join Date: Apr 2004
  • Posts: 288
    • Show only replies by Rebel-CD32
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #7 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.
Amiga user forever.
 

Offline Rebel-CD32

  • Sr. Member
  • ****
  • Join Date: Apr 2004
  • Posts: 288
    • Show only replies by Rebel-CD32
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #8 on: May 09, 2009, 11:47:20 AM »
Ah, Piru, you beat me to it ;-)
Amiga user forever.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #9 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.
int p; // A
 

Offline bloodline

  • Master Sock Abuser
  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 12114
    • Show only replies by bloodline
    • http://www.troubled-mind.com
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #10 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 :-)

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16882
  • Country: gb
  • Thanked: 6 times
    • Show only replies by Karlos
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #11 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?
int p; // A
 

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #12 on: May 09, 2009, 02:54:35 PM »
There is TLSFmem. From the readme:

***************************************************************************
TLSFMem is blindly fast and will reduce memory fragmentation significantly!
***************************************************************************

MorphOS 2 also implements TLSF memory allocator.
My Amigas: A500, Mac Mini and PowerBook
 

Offline Cass

  • Hero Member
  • *****
  • Join Date: Apr 2003
  • Posts: 826
  • Country: 00
    • Show only replies by Cass
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #13 on: May 09, 2009, 03:10:58 PM »
@ sim085
Try PoolMem , or just add to the final Startup-sequence line :
Quote

LoadWB -debug

to get a "Flush" menu option ;-)

"If we don't got it, you don't want it!"
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Does workbench 3.1 ever reclaim memory back?
« Reply #14 on: May 09, 2009, 03:29:04 PM »