Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: Amiduffer 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?
-
It has happened to me. Have you tried running the program via CLI instead?
-
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 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.
-
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?
-
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.
-
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.
-
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.
-
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.
-
"Dave, my mind is going..."
*SCNR*:lol:
-
Could it be that these machines are reaching an age where senility is starting to set in?
Damn, whered' I put my functions?