Welcome, Guest. Please login or register.

Author Topic: Lost memory?  (Read 2107 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline AmidufferTopic starter

  • Hero Member
  • *****
  • Join Date: Sep 2005
  • Posts: 1601
    • Show only replies by Amiduffer
    • http://www.geocities.com/laverdiereaf/
Lost memory?
« on: June 17, 2009, 10:21:19 PM »
I really wasn't sure whether this was a software or hardware issue, but, what the heck, I hope someone can answer this nagging question.

After I quit a program, it seems that I'll have lost a meg or two of fast ram memory which I won't get back until I reboot. This becomes an annoyance if I'm running ImageFX in particular, since it seems to need as much as possible for some processes, and with just 8 megs, it runs out quick. How can you get all your memory back after you quit a program? I vaguely recall there are programs available on Aminet, but which ones act to find your lost memory?
Amiga 3000D UP and running! Hear that clicking. 8)
Amiga 3000D & 4000D in storage sadly.
 

Offline ElPolloDiabl

  • Hero Member
  • *****
  • Join Date: May 2009
  • Posts: 1702
    • Show only replies by ElPolloDiabl
Re: Lost memory?
« Reply #1 on: June 17, 2009, 10:34:08 PM »
It has happened to me. Have you tried running the program via CLI instead?
Go Go Gadget Signature!
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Lost memory?
« Reply #2 on: June 17, 2009, 10:34:50 PM »
I take it "avail flush" doesn't work?

Memory isn't lost per se, but it can be leaked. A buggy bit of code may allocate some memory and then forget to release it. All current versions of the standard C/C++ library track all allocations through  the malloc() / new and will release it on exit. However, if an application is using exec AllocMem() directly and doesn't free it, it can be "lost" from the system after application exit
int p; // A
 

Offline AmidufferTopic starter

  • Hero Member
  • *****
  • Join Date: Sep 2005
  • Posts: 1601
    • Show only replies by Amiduffer
    • http://www.geocities.com/laverdiereaf/
Re: Lost memory?
« Reply #3 on: June 18, 2009, 04:45:39 AM »
Quote from: Karlos;511896
I take it "avail flush" doesn't work?

Memory isn't lost per se, but it can be leaked. A buggy bit of code may allocate some memory and then forget to release it. All current versions of the standard C/C++ library track all allocations through  the malloc() / new and will release it on exit. However, if an application is using exec AllocMem() directly and doesn't free it, it can be "lost" from the system after application exit


I think I tried Avail Flush in shell, and just got an error.
Amiga 3000D UP and running! Hear that clicking. 8)
Amiga 3000D & 4000D in storage sadly.
 

Offline Daedalus

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 893
    • Show only replies by Daedalus
    • http://www.robthenerd.com
Re: Lost memory?
« Reply #4 on: June 18, 2009, 08:46:58 AM »
An error? That's strange indeed, because avail flush should just return the memory statistics, even if it's unable to flush any unused libraries etc. Have you noticed if this happens after running particular applications? Or if it's something like when you're online and use application X?
Engineers do it with precision
--
http://www.robthenerd.com
 

Offline smf

Re: Lost memory?
« Reply #5 on: June 18, 2009, 12:50:25 PM »
Your system might be infected with a virus, many years ago my computer started to act funny and not release memory, it turned out that it was infected with some virus called fungus/lsd.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Lost memory?
« Reply #6 on: June 18, 2009, 02:20:47 PM »
Quote from: Amiduffer;511935
I think I tried Avail Flush in shell, and just got an error.


That's definitely not supposed to happen. Was it a "Recoverable Alert" error?

If so, it's highly likely the free memory list has become corrupted. This can be down to a bad bit of code trying to free the same block of memory twice.
int p; // A
 

Offline AmidufferTopic starter

  • Hero Member
  • *****
  • Join Date: Sep 2005
  • Posts: 1601
    • Show only replies by Amiduffer
    • http://www.geocities.com/laverdiereaf/
Re: Lost memory?
« Reply #7 on: June 18, 2009, 07:24:02 PM »
That doesn't sound very nice. Is that all that is required? Just typing AVAIL FLUSH in a shell? I better try again just to be sure.
Amiga 3000D UP and running! Hear that clicking. 8)
Amiga 3000D & 4000D in storage sadly.
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Lost memory?
« Reply #8 on: June 18, 2009, 08:20:59 PM »
Quote from: Amiduffer;512118
That doesn't sound very nice. Is that all that is required? Just typing AVAIL FLUSH in a shell? I better try again just to be sure.

It's relatively easy to make sure memory gets freed when a program quits, even if the program was badly written and forgot to free it. If the program only uses the C standard malloc()/calloc()/realloc()/free() family of functions (or C++ new/new[]/delete/delete[]), since the standard library can keep track of all allocations. If the application uses AmigaOS memory pools, it is also possible to ensure memory is freed. Only direct calls to AllocMem() that are never freed are likely to cause genuine leaks on exit. This is compounded by the fact that under AmigaOS, you can free bits of an allocated block of memory. That's not easy to track.

Freeing the same memory twice isn't something that is easy to protect against for any system. My own code uses a tracking system that knows all the blocks that were allocated by it and will throw an exception when any code tries to free something not in that list. However, this doesn't come for free, you have to step through the list of all allocated blocks and check the pointer doesn't match any of them. I'm pretty sure the C standard library is capable of doing this (and in current versions of glibc I think it does), but the standard makes it clear that freeing memory at the same address twice is undefined and bad.

If you free memory using AmigaOS FreeMem() and give it an area that wasn't allocated with AllocMem() in the first place, you basically trash exec's free memory list. That tends to make the system unstable.

It isn't the Avail command that is to blame, it's whatever left the free memory list in a state.
« Last Edit: June 18, 2009, 08:24:42 PM by Karlos »
int p; // A
 

Offline Zac67

  • Hero Member
  • *****
  • Join Date: Nov 2004
  • Posts: 2890
    • Show only replies by Zac67
Re: Lost memory?
« Reply #9 on: June 18, 2009, 08:45:18 PM »
"Dave, my mind is going..."
*SCNR*:lol:
 

Offline T3000

  • Hero Member
  • *****
  • Join Date: Dec 2003
  • Posts: 617
    • Show only replies by T3000
    • http://www.rcfreas.com
Re: Lost memory?
« Reply #10 on: June 24, 2009, 02:40:59 PM »
Could it be that these machines are reaching an age where senility is starting to set in?
Damn, whered' I put my functions?