home *** CD-ROM | disk | FTP | other *** search
-
- Fragit 2.0
- A simple dynamic memory thrasher for the Amiga
- By Justin V. McCormick
-
-
- Notices and Copyrights
-
- Unless otherwise noted, all files are:
- Copyright © 1989 Justin V. McCormick. All Rights Reserved.
-
- This code may be freely used, modified, and distributed in any
- form for either commercial or personal profit or non-profit, so
- long as this Copyright notice remains prominently attached to
- the source code. Please contact the author for special
- arrangements.
-
-
- Disclaimers:
-
- In any case, the author makes no specific performance claims
- for this code and assumes no responsibility to maintain or
- support this code. Additionally, the author bears no liability
- or responsibility should the use of this code result in loss of
- data or sleep.
-
-
- About Fragit:
-
- Fragit 1.0 was a quick hack written about September of 1988.
- It came about due to discussion on BIX about Amiga memory
- fragmentation and garbage collection.
-
- Unfortunately, Fragit 1.0 contained a silly bug and was
- randomly corrupting its MinList. Bryce Nesbitt of CBM kindly
- tracked this problem down in April of 1989, and I fixed the
- problem in V1.1 (never publicly released).
-
- Recently, Bryce made some good suggestions on improving the
- user interface to make Fragit part of a programmers debugging
- toolkit. I have been busy finishing up a major commercial
- project, but now that I have a small amount of free programming
- time I decided to give Fragit a full face lift for Version 2.0.
- I hope you enjoy(?) using it.
-
- Justin V. McCormick, July 24th, 1989
-
- I can be reached via:
-
- BIX: jmccormick
-
- PLINK: jvm
-
- PHONE: 303-290-8429
-
- USMAIL: Justin V. McCormick
- 8330 E. Quincy Ave.
- Bldg. C #312
- Denver CO, 80237
-
-
- Theory of Operation
-
- Fragit allocates random sized blocks of memory, using
- RangeRand() to generate psuedo-random size values that range
- from 16 bytes to 50000 bytes (by default). Thus, both odd and
- even fragment sizes are generated, but all sizes are "legal"
- from an Exec viewpoint -- the allocator just rounds the sizes up
- to the next 8 byte size boundary.
-
- These random sized fragments are linked together into a
- dynamically allocated linked-list of Exec style MinNodes.
- AddHead() is used to insert new nodes (called a FragNode) at the
- head of the list.
-
- Fragit checks AvailMem() before it allocates a new random
- fragment; if the available memory has dropped below the limit
- set (which defaults to 100K), Fragit _randomly_ deallocates one
- of the nodes in the MinList of FragNodes. This is done by
- generating a random number N such that:
-
- 0 <= N < (number of nodes / 2)
-
- The current list is then scanned until the Nth element is found.
- If Fragit hits the end of the list before finding the Nth
- element, it merely starts at the head of the list again. The
- node is then Remove()'ed from the list and deallocated. Of
- course, Fragit checks to see if the list is empty before trying
- to remove or deallocate a node!
-
- This means that if AvailMem(0L) is less than the low memory
- limit, Fragit starts deallocating random fragments in the list
- until there is enough memory to attempt allocating another
- fragment. When AvailMem(0L) shows that there is more system
- memory than the low memory limit, it attempts to allocate
- and add another fragment to the head of the list.
-
- The result is a dynamic allocation nightmare: thousands of
- memory fragments are being created and destroyed continuously.
- In a matter of moments, you can fragment free memory so badly
- that you cannot resize a window! The idea is to put stress on
- the AllocMem()/FreeMem() parts of an application undergoing
- debugging by simulating a very busy, highly fragmented memory
- environment. Additionally, you can set the Timer Speed control
- in Fragit to a low value and effectively "hog" the CPU.
-
- I recommend using Perfmon in combination with Fragit to get a
- a better understanding of how Fragit affects the Amiga
- multitasking system.
-
-
- Compiling Fragit
-
- Fragit should compile under both Lattice 5.02 and Manx 3.6a
- with no warnings. Also, Fragit passes Gimpel Lint with
- only one warning (a spurious one). Please use the appropriate
- makefile included and scan the source code file, fragit.c, for
- more information.
-
-
- Using Fragit
-
- Fragit can be run from the Workbench or from the CLI. You will
- probably want to "RUN >NIL: Fragit" if you are launching it from
- the CLI; Fragit does not need a console and you can safely
- detach the CLI that launched Fragit.
-
-
- The Info Header:
-
- Fragit opens a control and display window on the Workbench. This
- window contains a information header that looks like this:
-
- Fragments Failures Allocated
- 0 0 0
-
- "Fragments" is the number of nodes currently allocated by
- Fragit. "Failures" is a count of the number of allocation
- attempts that failed. "Allocated" is the total number of bytes
- used by the nodes currently allocated by Fragit.
-
-
- The Memory Stats Monitor:
-
- Underneath the information header is a display of the current
- system memory statistics, in the same format as used by "AVAIL".
-
-
- The Settings String Gadgets:
-
- There are four string gadgets below the memory statistics.
- You can click inside these and type a new setting at any time.
- Here is a description of what each gadget controls and the
- units used:
-
- Low Mem Limit:
- In BYTES, Threshold at which Fragit will stop allocations.
-
- Timer Speed:
- In MICROSECONDS, Time between allocations and info updates.
-
- Min Frag Size:
- In BYTES, Smallest fragment size that Fragit will allocate.
-
- Max Frag Size:
- In BYTES, Largest fragment size that Fragit will allocate.
-
-
- The Command Gadgets:
-
- At the bottom of the window are three pushbutton gadgets.
- You can click on these at any time to perform the following:
-
- STOP:
- Stop allocating/freeing fragments. Note that Fragit is still
- updating the Memory Stats Monitor at the current Timer Speed.
-
- START:
- Begin thrashing memory at the current Timer Speed.
-
- ALLOC:
- Allocates all ram down to the current Low Mem Limit, using
- fragments that are Max Frag Size each. Note that if you click
- on ALLOC and have a very small Max Frag Size specified, it may
- take quite some time to use all the ram. You can click on the
- STOP gadget to abort the allocation process at any time.
-
- PURGE:
- Free the current list of nodes allocated, returning all fragments.
-
-
- Keyboard Equivalents:
-
- There are some simple keyboard shortcuts that can be used when
- the Fragit window is active:
-
- SPACE or 's' - STOP/START toggle
- 'p' - Same as PURGE
- ESCAPE - Same as clicking on the CLOSEWINDOW gadget.
-
-
- Changing the Defaults:
-
- The initial defaults for Fragit can be customized by editing
- the Fragit.info icon file using the Workbench "Info" tool. The
- following TOOL TYPES names (upper case only) are recognized:
-
- MINMEM=<number of bytes>
- Sets the Low Mem Limit.
-
- SPEED=<number of microseconds>
- Sets the Timer Speed.
-
- MINFRAG=<number of bytes>
- Sets the Min Frag Size, should be smaller than MAXFRAG, cannot
- be smaller than 16 bytes (the size of a FragNode).
-
- MAXFRAG=<number of bytes>
- Sets the Max Frag Size, should be larger than MINFRAG
-
- FAST=1
- Fragit will only allocate nodes from FAST_MEM.
-
- CHIP=1
- Fragit will only allocate nodes from CHIP_MEM.
-
- MEMTYPE=<type_of_mem in decimal>
- Fragit will only allocate nodes from the type of memory you specify.
- For instance, MEMF_PUBLIC is defined as (1L << 0). Thus, you could
- set MEMTYPE=1 to get only MEMF_PUBLIC allocations.
-