Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (03/04/90)
Submitted-by: davids@ucscb.UCSC.EDU (60116000) Posting-number: Volume 90, Issue 095 Archive-name: util/availmem1.10 [ uuencoded executable included. ...tad ] I like knowing the number of bytes of free chip and fast memory I have. Unfortunatly, every other memory counter I've run into displays free memory in kilobytes. Maybe I'm fussy about this because I've used Workbench for so long...see what it does to you? :-) Anyway, I whipped up this little program that continuously displays the amount of free fast and chip memory, along with the total. It also displays the largest free block of each kind of memory, so you can keep an eye on fragmentation. I've included the source, so feel free to tinker, but please let me know before you release a modified version. Thanks. -Dave Schreiber davids@slugmail.ucsc.edu (should be able to reach me at all times) #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: AvailMem.c AvailMem.doc AvailMem.h AvailMem.info.uu # AvailMem.uu # Wrapped by tadguy@xanth on Sat Mar 3 22:14:48 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'AvailMem.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'AvailMem.c'\" else echo shar: Extracting \"'AvailMem.c'\" \(3375 characters\) sed "s/^X//" >'AvailMem.c' <<'END_OF_FILE' X/*------------------------- AvailMem V1.10 ----------------------------*/ X/*Written and copyright (c)1988, 1989, 1990 by Dave Schreiber. All rights*/ X/*reserved. This program may not be sold, but reasonable charges for */ X/*media, duplication, shipping/handling, etc. are permitted. */ X/*---------------------------------------------------------------------*/ X/*Keeps a running count of the amount of FAST, CHIP, and total memory */ X/*free. Updates every .7 seconds. With a stack size of 4K, it takes */ X/*up about 12K of RAM. Compiled under Lattice C V5.02 */ X/*----------------------------- Enjoy ---------------------------------*/ X/*Version history: */ X/* 1.10 - Added a counter of the largest block free for FAST, CHIP, and*/ X/* total memory */ X/* 1.03 - First release to the public. Included on Fred Fish disk #285*/ X/*---------------------------------------------------------------------*/ X X X/*Standard #include files*/ X#include <exec/types.h> X#include <exec/exec.h> X#include <intuition/intuition.h> X X/*Window and IntuiText definitions*/ X#include "AvailMem.h" X Xstruct IntuitionBase *IntuitionBase; /*Library base pointers*/ Xstruct GfxBase *GfxBase; X Xvoid MainLoop(); Xvoid MakeString(); X X#define Rp Wdw->RPort X X /*Using _main() keeps AmigaDOS from opening an extra */ X_main() /*console window when AvailMem is run from Workbench.*/ X{ X if((IntuitionBase=(struct IntuitionBase *) /*Open Intuition*/ X OpenLibrary("intuition.library",0))==NULL) X exit(10); X /*Open Graphics*/ X if((GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0))==NULL) X { X CloseLibrary(IntuitionBase); /*Like it really matters...*/ X exit(20); X } X X MainLoop(); X X CloseLibrary(GfxBase); /*Close the libraries*/ X CloseLibrary(IntuitionBase); X} X Xvoid MainLoop() /*The main loop*/ X{ X struct Window *Wdw; /*Window pointer*/ X ULONG c,f; X X /*Open the window*/ X if((Wdw=(struct Window *)OpenWindow(&NewWindowStructure1))==NULL) X exit(30); X X PrintIText(Rp,&IText1,-6,2); X X /*while the close gadget wasn't pressed...*/ X while( ( GetMsg(Wdw->UserPort) ) == NULL) X { /*For each possibility, get the memory count, convert it to text, X /*put it into the appropriate intuitext structure,*/ X X c=AvailMem(MEMF_LARGEST|MEMF_CHIP); X f=AvailMem(MEMF_LARGEST|MEMF_FAST); X MakeString(IText12.IText,(c < f) ? f : c); X MakeString(IText11.IText,c); X MakeString(IText10.IText,f); X X c=AvailMem(MEMF_CHIP); X f=AvailMem(MEMF_FAST); X MakeString(IText9.IText,c+f); X MakeString(IText8.IText,c); X MakeString(IText7.IText,f); X X PrintIText(Rp,&IText7,-6,2); /*and print it*/ X Delay(35); /*Wait for .7 seconds, then do the whole thing again*/ X } X CloseWindow(Wdw); /*Close the window*/ X} X Xvoid MakeString(string,amt) /*Convert amt to a string, put into 'string'*/ Xchar *string; /*and pad out with spaces*/ XULONG amt; X{ X BYTE c; X stcu_d(string,amt,8); /*Convert number into text*/ X for(c=strlen(string);c<8;c++) X string[c]=' '; /*Pad out with spaces*/ X X string[8]=NULL; /*And terminate with a NULL*/ X} END_OF_FILE if test 3375 -ne `wc -c <'AvailMem.c'`; then echo shar: \"'AvailMem.c'\" unpacked with wrong size! fi # end of 'AvailMem.c' fi if test -f 'AvailMem.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'AvailMem.doc'\" else echo shar: Extracting \"'AvailMem.doc'\" \(1118 characters\) sed "s/^X//" >'AvailMem.doc' <<'END_OF_FILE' X AvailMem version 1.10 X X(c)1988, 1989, 1990 by Dave Schreiber. All rights reserved. AvailMem is Xfreely distributable. It must be distributed without cost, except for Xsmall charges for media, shipping, copying, labels, and applicable taxes. X X I like knowing the number of bytes of free chip and fast memory I have. XUnfortunatly, every other memory counter I've run into displays free memory Xin kilobytes. Maybe I'm fussy about this because I've used Workbench for Xso long...see what it does to you? :-) Anyway, I whipped up this little Xprogram that continuously displays the amount of free fast and chip memory, Xalong with the total. It also displays the largest free block of each Xkind of memory, so you can keep an eye on fragmentation. I've included the Xsource, so feel free to tinker, but please let me know before you release Xa modified version. Thanks. X X-Dave Schreiber X davids@slugmail.ucsc.edu (should be able to reach me at all times) X X Alternate addresses: X davids@ucscb.ucsc.edu (during the school year) X davids@cup.portal.com (during the summer/vacations/etc.) X END_OF_FILE if test 1118 -ne `wc -c <'AvailMem.doc'`; then echo shar: \"'AvailMem.doc'\" unpacked with wrong size! fi # end of 'AvailMem.doc' fi if test -f 'AvailMem.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'AvailMem.h'\" else echo shar: Extracting \"'AvailMem.h'\" \(1205 characters\) sed "s/^X//" >'AvailMem.h' <<'END_OF_FILE' X Xstruct IntuiText IText12 = { X 1,0,JAM2, X 154,53, X NULL, X " ", X NULL X}; X Xstruct IntuiText IText11 = { X 1,0,JAM2, X 154,43, X NULL, X " ", X &IText12 X}; X Xstruct IntuiText IText10 = { X 1,0,JAM2, X 154,33, X NULL, X " ", X &IText11 X}; X Xstruct IntuiText IText9 = { X 1,0,JAM2, X 73,53, X NULL, X " ", X &IText10 X}; X Xstruct IntuiText IText8 = { X 1,0,JAM2, X 73,43, X NULL, X " ", X &IText9 X}; X Xstruct IntuiText IText7 = { X 1,0,JAM2, X 73,33, X NULL, X " ", X &IText8 X}; X Xstruct IntuiText IText6 = { X 1,0,JAM2, X 154,23, X NULL, X "Largest:", X &IText7 X}; X Xstruct IntuiText IText5 = { X 1,0,JAM2, X 73,23, X NULL, X "Total:", X &IText6 X}; X Xstruct IntuiText IText4 = { X 1,0,JAM2, X 15,12, X NULL, X "Available memory (in bytes):", X &IText5 X}; X Xstruct IntuiText IText3 = { X 1,0,JAM2, X 14,53, X NULL, X "Total:", X &IText4 X}; X Xstruct IntuiText IText2 = { X 1,0,JAM2, X 15,43, X NULL, X "Chip:", X &IText3 X}; X Xstruct IntuiText IText1 = { X 1,0,JAM2, X 15,33, X NULL, X "Fast:", X &IText2 X}; X X#define IntuiTextList1 IText1 X Xstruct NewWindow NewWindowStructure1 = { X 356,26, X 243,68, X 0,1, X CLOSEWINDOW, X WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE, X NULL, X NULL, X "AvailMem V1.10", X NULL, X NULL, X 5,5, X 640,200, X WBENCHSCREEN X}; END_OF_FILE if test 1205 -ne `wc -c <'AvailMem.h'`; then echo shar: \"'AvailMem.h'\" unpacked with wrong size! fi # end of 'AvailMem.h' fi if test -f 'AvailMem.info.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'AvailMem.info.uu'\" else echo shar: Extracting \"'AvailMem.info.uu'\" \(1604 characters\) sed "s/^X//" >'AvailMem.info.uu' <<'END_OF_FILE' Xbegin 664 AvailMem.info XMXQ```0``````*P`3`#8`'P`&``,``0`G7+``)V<8````````````````````J XM`````R8`()K0`````````!0````(``````````````^@```````V`!\``@`!6 XM?U`#````````88888888``!AAAAAAA@``,,,,,,,,```PPPPPPPP``//////: XM//```\\\\\\\\``'GGGGGGG@``>>>>>>>>``#SSSSSSSP``////////`````8 XM````````````````````````````````````````````````````````````` XM````````````````````````````````````````````````````````````` XM````````````````````````````````````````````````````````````` XM``````````\\\\\\\\``#SSSSSSSP```````````````````````````````X XM````````````````````````````````````````````````````````````` XM```````PPPPPPPPP`#########``_________`#________\`/________P`^ XM_________`#________\`/________P`_________`#________\`/______) XM__P`_________`#________\`/________P`_________`#________\`/__' XM______P`_________`#________\`/________P`,,,,,,,,,``PPPPPPPPPV XM```````````````````V`!\``@`!@4`#````````88888888``!AAAAAAA@`8 XM`,,,,,,,,```PPPPPPPP``////////```\\\\\\\\``'GGGGGGG@``>>>>>>3 XM>>``#SSSSSSSP``////////````````````````````````'AX>'AX>```>') XMAX>'AX``#,S,S,S,P``,S,S,S,S```#`P,#`P,```,#`P,#`P``!@8&!@8&`R XM``&!@8&!@8```P,#`P,#```#`P,#`P,````````````````````````#`P,#V XM`P,```,#`P,#`P````````````````````````\\\\\\\\``#SSSSSSSP```0 XM````````````````````````````````````````````````````````````` XM```````````````````````````````````PPPPPPPPP`#########``____9 XM_____`#________\`/AX>'AX>'P`^'AX>'AX?`#S,S,S,S,\`/,S,S,S,SP`C XM_S\_/S\_/`#_/S\_/S\\`/Y^?GY^?GP`_GY^?GY^?`#\_/S\_/S\`/S\_/S\< XM_/P`_________`#________\`/S\_/S\_/P`_/S\_/S\_`#________\`/__@ XC______P`,,,,,,,,,``PPPPPPPPP`````````````````0#_4 X`` Xend Xsize 1115 END_OF_FILE if test 1604 -ne `wc -c <'AvailMem.info.uu'`; then echo shar: \"'AvailMem.info.uu'\" unpacked with wrong size! fi # end of 'AvailMem.info.uu' fi if test -f 'AvailMem.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'AvailMem.uu'\" else echo shar: Extracting \"'AvailMem.uu'\" \(5280 characters\) sed "s/^X//" >'AvailMem.uu' <<'END_OF_FILE' Xbegin 664 AvailMem XM```#\P`````````&``````````4```&]````@0```0D````%````%0```!$`U XM``/I```!O21()`!)^0````!'^0```GQR`"`\````:F`")L%1R/_\+'@`!"E.N XM`K0I3P*\0JP"N"9N`11P`"(\```P`$ZN_LXI:P"8`K!*JP"L9P``<"`/D*\`' XM!`:`````@"E``H!A``$N(&L`K-'(T<@B:``0T\G3R2`"<@`2&2E)`L30@5*`: XM0F=2@`)`__Z?P%6`0G<(`"`"4X#4@1^R```@`%."4<C_]A^\`"`@`%."'[$@M XM`"``4<K_^")/+PE@``!X*6L`.@*`<']2@-&L`H!A``#"0>L`7$ZN_H!!ZP!<P XM3J[^C"E``K@O`"1`("H`)&<2+&P$%"!`(B@``"E!`K!.KO^"(BH`(&<:)#P`C XM``/M3J[_XBE``L!G"N6(($`G:``(`*0@;`*X+PA(;`)\(&@`)"EH``0"Q$ZZO XM`(!.N@!T<`!@!"`O``0O`"`L`JAG!"!`3I!.N@5T+'@`!")L!!1.KOYB3KH`D XM5DJL`KAG&B(L`L!G!$ZN_]PL>``$3J[_?")L`KA.KOZ&(!\N;`*\3G5P9&"T" XM0_H`$'``3J[]V"E`!!1G[$YU9&]S+FQI8G)A<GD`3OD`````<&%.=4YU2.<'B XM,"XO`!@F;P`<+"\`("\'3KH#U%A/)$`@"F8$</]@-@@J``,``V<02'@``D*GD XM+P=.N@"43^\`#"\&+PLO*@`$3KH!,$_O``PJ`$JL`I1G!'#_8`(@!4S?#.!.G XM=0``````````<&$N;`*\3KH"`DAY````%$ZZ`*```````````'!A(&\`!"`(S XM2AAF_%-(D<`@"$YU```@+P`((&\`!$Y5__0B3W(*3KH"K`9!`#`2P4J`9O`@( XM"1#AO\EF^D(0D(].74YU``!(YP\0+B\`&"PO`!PJ+P`@+P=.N@,,6$\F0"`+Y XM9@1P_V`>+P4O!B\K``1.N@#@3^\`#"@`2JP"E&<$</]@`B`$3-\(\$YU````* XM``````!P84CG`Q`N+P`01^P!V"`+9S0(*P`"`!MF*`@K``$`&V<@("L`!)"K0 XM`!`L`$J&9Q(O!B\K`!`O*P`<3KK^KD_O``PF4V#(+P=.N@-86$],WPC`3G4`O XM`````````'!A2.<W$"XO`!PF;P`@+"\`)$JL`JQG!$ZZ`JA"K`*4(@<D"R8&] XM+&P$%$ZN_]`J`'#_NH!F#DZN_WPI0`*4<`4I0`00(`5,WPCL3G4`````````Q XM`````````````````'!A2.<_`"XO`!PL+P`@*B\`)$JL`JQG!$ZZ`DA"K`*45 XM(`53@"(')`8F`"QL!!1.KO^^*`!P_[B`9@Y.KO]\*4`"E'`6*4`$$"`%#(``' XM```"9Q8,@`````%G"$J`9A@@!F`4(`30AF`.(@=T`'8`+&P$%$ZN_[Y,WP#\H XM3G4``"\'+B\`"$JL`JQG!$ZZ`=8B!RQL!!1.KO_<<``N'TYU3E7_L"\.2JP"# XMR&820_H`B'``+'@`!$ZN_=@I0`+(<``@;`+$$"C__T/M_[!@`A+84X!D^G``E XM(&P"Q!`H__]"-0BP0>W_L"E(`DQ(>``H2'@`^G``+P`O`$AL`FAR`"\!2&P"Y XM5"\!3KH!K$AX`!1.N@'8+&W_K$Y=3G4J*B!3=&%C:R!/=F5R9FQO=R`J*@``R XM15A)5```:6YT=6ET:6]N+FQI8G)A<GD`````````````````2H!J```>1(!*@ XM@6H```Q$@6$``"!$@4YU80``&$2`1(%.=4J!:@``#$2!80``!D2`3G4O`DA!X XM-`%F```B2$!(04A"-`!G```&A,$P`DA`-`"$P3`"2$(R`B0?3G4O`W80#$$`L XM@&0```;AF5%##$$(`&0```;IF5E##$$@`&0```;EF55#2D%K```&XYE30S0`$ XMYJA(0D)"YJI(0X#!-@`P`C0#2$'$P9""9```"%-#T(%D_G(`,@-(0^>X2$#!& XM028?)!].=2\'+B\`"'``*4`"E$J':R*^K`'4;!P@!^>`0>P"T$JP"`!G#B`'F XMYX!![`+0T<`@"&`(<`DI0`00<``N'TYU``````````````````!(YP$"<``B! XM/```,``L>``$3J[^SBX``H<``#``2H=F!'``8"!*K`*L9Q@@;`*L3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````!`````````'*```!Q````>X```&^`````0``: XM``,```'B````!`````0```'Z```!U@```@````'<`````P````4```'T```!= XMZ````=`````````#\@```^H```"?("`@("`@("````$``0``F@`U````````+ XM````````("`@("`@("````$``0``F@`K`````````!X````*("`@("`@("``O XM``$``0``F@`A`````````#P````H("`@("`@("````$``0``20`U````````A XM`%H```!&("`@("`@("````$``0``20`K`````````'@```!D("`@("`@("``R XM``$``0``20`A`````````)8```""3&%R9V5S=#H```$``0``F@`7````````# XM`+0```"@5&]T86PZ```!``$``$D`%P````````#2````OD%V86EL86)L92!M2 XM96UO<GD@*&EN(&)Y=&5S*3H```$``0``#P`,`````````.X```#:5&]T86PZ8 XM```!``$```X`-0````````$@```!#$-H:7`Z``$``0``#P`K`````````3P`J XM``$H1F%S=#H``0`!```/`"$````````!5@```4)!=F%I;$UE;2!6,2XQ,```_ XM`60`&@#S`$0``0```@`````.``````````````%P````````````!0`%`H``$ XMR``!:6YT=6ET:6]N+FQI8G)A<GD`9W)A<&AI8W,N;&EB<F%R>0``````*```K XM`?H```````````````````````````````````````````(<````````````9 XM````````````````````````````````````````````````````````````` XM````````````````__\````.``X```````````````#__P````0`!```````@ XM``2B```"0/__````!``$````````!+@````````#[`````(````````"=```1 XM`F`````;`````@```F0```'Z```!V````9H```%L```!:````5(```%.```!- XM.````30```$<```!&````.H```#F````S@```,H```"P````K````)(```".' XM````=````'````!6````4@```#@````T````%@````````/R```#Z0````4OC XM#BQY```$%"(O``A.KO\Z+%].=0```^P````!`````@````0````````#\```0 XM``)?1&5L87D````````````````#\@```^D````5+PXL>0```K0B+P`(3J[_R XM*"Q?3G4O#BQY```"M"!O``A.KOZ,+%].=2\.+'D```*T(F\`"$ZN_F(L7TYU4 XM+PXL>0```K0B;P`(("\`#$ZN_=@L7TYU```#[`````0````"````0````"P`, XM```8````!`````````/P`````U]/<&5N3&EB<F%R>0```#P````$7T-L;W-EM XM3&EB<F%R>0```````"@````"7T=E=$US9P`````4`````U]!=F%I;$UE;0``G XM```````````````#\@```^D````1+PXL>0```L@@;P`(3J[_N"Q?3G4O#BQY8 XM```"R"!O``A.KO\T+%].=2\.+'D```+(3.\#```(3.\``P`03J[_*"Q?3G4`/ XM``/L`````P````(````L````&`````0````````#\`````-?4')I;G1)5&5X8 XM=``````H`````U]/<&5N5VEN9&]W`````!0````#7T-L;W-E5VEN9&]W````L X)``````````/RU X`` Xend Xsize 3744 END_OF_FILE if test 5280 -ne `wc -c <'AvailMem.uu'`; then echo shar: \"'AvailMem.uu'\" unpacked with wrong size! fi # end of 'AvailMem.uu' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>. Mail comments to the moderator at <amiga-request@cs.odu.edu>. Post requests for sources, and general discussion to comp.sys.amiga.