MemMon -- A Case History

MemMon Instrumentation

               ...

      StrLen(ts) = slen;
      StrLoc(ts) = s;
      if (!collect(Strings, slen))
         return NULL;
      s = StrLoc(ts);
      }
   MMStr(slen);                    /* string allocation */
   strtotal += slen;
               ...

      struct region *rp = NULL;
      if (DiffPtrs(blkend, blkfree) < nbytes) {
      if (!collect(Blocks, nbytes))
          return NULL;
      }
   MMAlc((word)nbytes, t_code);    /* block allocation */
            ...

  if (InRange(blkbase, block, blkfree)) {
      type = BlkType(block);
      if ((uword)type <= MaxType) {
         endblock = block + BlkSize(block);
         MMMark(block, (int)type);  /* block marked */
         }

MemMon Output

##  Icon MemMon output
#
#   program: ./rsg
#   date:    Fri May 18 09:35:34 1990

4< 155484:68160/68160 223680:0/46080 269760:0/92160
2+4524F4528+2048A6578+256A6836+202A7040+10000X
0"
>
= 155484:68160/68160 223680:0/46080 269760:0/92160
5L23lL21l16T10h7eL9lLl80+7%rteLlLl115+%rteLlLl150+%rteLlLl185+%rteLlLl
220+%rte6RLlLl255+%rteRLlLl296+%rteRLlLl337+%rtLl2478+2048A41"5ueL23l10c
LlcRccRccRccRccc397+%rt35"ueLlcLlcRccRccRccc599+%rt32"ueLlcLlcRccRccRc
cc775+%rt148"ueLlcLlccc951+%rt46"ueLlcLlcRcRcRcRcRcRcRcc1059+%rt50"ueL
lcLlcccLlcccLlcccLlcccLlccc1269+%rt56"ueLlcLlcccLlcccLlcccLlcccLlccc1609+%rt
84"ueLlcLlcccLlcccLlcccLlcccLlcccLlcccLlcccLlcccLlcclc1949+%rt64"ueLlc
LlccRccLlccRccLlccRccLlccRccRcc2544+%rt62"ueLlcLlcccLlcccLlcccLlcccLlc
ccLlccc2916+%rt34"ueLlcLlcccLlcccLlccc3314+%rt28"ueLlcLlcRccRcc3538+%rt
17"ueLlcLlcccLlccc3678+%rt54"ueLlcLlcccLlcccLlcccLlcccLlcccLlcccLlcccL
lccc3844+%rt37"ueLlcLlcccLlcccLlcccLlccc4358+%rt8"uRL9lL21lL7lL9lL19l0"
138"L9lL17l1"L19lL15lL9lL25l18"1"L9lL21l8"2"L11lL17l4"L9lL17l7"1"L9lL13l
"L19lL11lL9lL21l5"1"L9lL17l3"1"L9lL13l9"1"L9lLl"LlL7l"428+ARL9lL21lL7l
L9lL19l0"138"L9lL17l1"L19lL15lL9lL25l3"1"L9lL21l7"2"L15lL17l6"L9lL21l9"
1"L9lL17l6"1"L9lL13l"L19lL11lL9lL21l11"1"L9lL17l18"1"L9lL13l6"1"L9lLl"
LlL7l"RL9lL21lL7lL9lL19l0"138"L9lL17l1"L19lL15lL9lL25l7"1"L9lL21l9"2"L
11lL17l4"L9lL17l6"1"L9lL13l"L19lL11lL9lL21l11"1"L9lL17l7"1"L9lL13l6"1"
L9lLl"LlL7l"RL9lL21lL7lL9lL19l0"138"L9lL17l1"L19lL15lL9lL25l18"1"L9lL21l
6"2"L15lL17l6"L9lL21l9"1"L9lL17l11"1"L9lL13l"L19lL11lL9lL21l7"1"L9lL17l

MemMon Visualization

MemMon Visualization Layout


MemMon Visualization Example

just prior to garbage collection:



data to be saved highlighted:



data to be discarded highlighted:



saved data compacted:

Using MemMon to Compare Programming Techniques

Concordance Program Using Strings:

global uses, lineno, width

procedure main(args)
   local word, line

   width := 15	# width of word field
   uses := table("")
   lineno := 0
   every tabulate(words())	# tabulate all the citations
   output()	# print the citations
end
          ...

procedure tabulate(word)
   if uses[word][-2 -:*lineno] == lineno then return
   else {
   uses[word] ||:= lineno || ", "	# new line number
   return
   }
end

procedure output()
   local word

   write()
   uses := sort(uses,3)	# sort citations
   while word := get(uses) do
      write(left(word, width), get(uses)[1:-2])
end

Concordance Program Using Lists:

          ...

procedure tabulate(word)
   if /uses[word] := [lineno] then return
   else {
   if uses[word][-1] ~= lineno then put(uses[word] ,lineno)
   return
   }
end
          ...

procedure output()
   local word, line, numbers

   write()
   uses := sort(uses,3) # sort citations
   while word := get(uses) do {
      line := ""
      numbers := get(uses)
      while line ||:= get(numbers) || ", "
      write(left(word, width), line[1:-2])
      }
end

Concordance Program Using Sets:



procedure tabulate(word)
   /uses[word] := set()
   insert(uses[word], lineno)
   return
end
          ...

procedure output()
   local word, line, numbers

   write()
   uses := sort(uses,3)
   while word := get(uses) do {
      line := ""
      numbers := sort(get(uses))
      while line ||:= get(numbers) || ", "
      write(left(word, width), line[1:-2])
      }
end

Concordance Program Using Tables:

procedure tabulate(word)
   /uses[word] := table()
   uses[word][lineno] := 1
   return
end
          ...

procedure output()
   local word, line, numbers

   write()
   uses := sort(uses,3)
   while word := get(uses) do {
   line := ""
   numbers := sort(get(uses),3)
   while line ||:= get(numbers) || ", " do
      get(numbers)
      write(left(word,width), line[1:-2])
      }
end

Different MemMon Palettes