CompuServe Thread

#Memory Munching

5 messages in this thread
#40894From: Dave WrightMay 7, 1994 7:20 PM
Hello. I've been messing around with the AMIGA since about 1985 or so. At work, I use PCs (sorry), so I am a little behind on this beast. I currently have an AMIGA 2000 with a 40MB drive and a 105MB drive, three 3.5" disks, 1 5.5" disk, and a 8088 bridgeboard. Miscellaneous other stuff of no significance. I am trying to write an app in Aztec 'C' V5.2 on this computer, and I have a conundrum. No matter what I write (and I've written about 5 apps), I have a memory management problem. Any application that I write, the first time the application runs, it burns up 10,992 bytes of memory. After that, I can run the app a thousand times, and all is well. This doesn't fit in with my experience on PCs, and I can't figure out what's going on. I operate on the assumption that all statics and globals are freed by the compiler, but this doesn't seem to be true. If not that, then the OS must be a little recalcitrant. Has any one run into this? Is there something that I've missed? I would appreciate any help you can provide. Thanx much. Dave Wright
#40897From: Jim ButterfieldMay 8, 1994 6:51 AM
It's possible that the memory reduction you see is from libraries that your program has invoked. Even though your program may CloseLibrary() the libraries that have been opened, they will be left in memory until (a) an explicit action "purges" them, or (b) memory is in short supply, at which time an auto-purge takes place. The reason: to save time next time somebody calls for the library. Try using the command AVAIL FLUSH; this forces a purge of currently unused libraries. If this doesn't bring you memory back, you may need to look further, to make sure you haven't left loose resources (screens, windows, whatever) lying around. –Jim
#40912From: Vic WagnerMay 9, 1994 3:20 PM
David, Are you opening a font? Or a library? and not closing it?
#40965From: Steve AhlstromMay 11, 1994 5:26 PM
David, First off, you might consider picking up a recent (and supported) C compiler … either SAS/C or DICE. If your program is opening any shared library or font the answer to your question is obvious … when a device or font is opened and properly closed when your program terminates, it remains in memory. It will remain in memory until that memory is needed for use. You can use the AVAIL command with the arguement "FLUSH" (ie. 1> avail flush) to remove all resident but unopened resources currently in memory. -sja
#41080From: Doug WalkerMay 18, 1994 5:05 PM
Hi David – To elaborate on Steve's answer (which is totally correct, even the part about upgrading compilers 8^) the Amiga OS caches certain types of data for future reference. This data includes disk-based shared libraries, fonts, and a few other resources. If the system starts to run low, the extra stuff is paged out for you. DOS is not really a good basis for comparison, but Microsoft Windows does do some of this kind of thing – for example, if you load a Windows DLL, Windows keeps it around in case you need it again. However, there are some gotchas to be aware of when programming the Amiga OS. The Amiga OS does *not* track most resources, so if you allocate something, you are in general responsible for freeing it (assuming you use the Amiga OS routines.) Most compiler libraries supply memory and file management functions like malloc(), fprintf(), etc. which track these resources for you and free them on exit, so if you're using standard ANSI C functions, you're OK; however, if you are using AllocMem() or Open() or any of the similar AmigaDOS functions, you need to free that stuff yourself. –Doug