[Oberon] PO2013 - Show Heap Blocks

Tomas Kral thomas.kral at email.cz
Wed Jun 17 17:52:27 CEST 2020

> Each run shows different values for list{0..3}, sometimes valid
> address, sometimes NIL(0).

This seems alright, when last block of a list is freed, or not yet
allocated, then list{32,64,128,*256} is just set to NIL.

I realised (thanks Joerg), to inspect heap, lists' address not needed,
only heapOrg, where all things happen.

This minimal code, shows any blocks not multiple of 20H, none, except
free space, if I got the idea right.

I am not seeing any blocks with mark >0, I could possibly do, when scan

MODULE Heap; (*TK 14.6.2020 show heap blocks*)

  VAR heapOrg, MemLim, heapLim: INTEGER;

    VAR p, q, mark, tag, size: LONGINT;
  BEGIN p := heapOrg;
    Out.String("heapOrg: "); Out.Hex(p); Out.Ln;
    REPEAT S.GET(p+4, mark); q := p; (*mark: 0 used, -1 freed, >0 to be freed*)
      IF mark = -1 THEN S.GET(p, size)
      ELSE S.GET(p, tag); S.GET(tag, size); (*size := p - q*) END ;
      IF (size MOD 32 # 0) & (size MOD 64 # 0) & (size MOD 128 # 0) & (size MOD 256 # 0) THEN
        Out.Hex(p); Out.Hex(size); Out.Hex(mark); Out.Ln; END ;
      INC(p, size)
    UNTIL p >= heapLim(*-30000H*)

  END Show;

BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim
END Heap.


Tomas Kral <thomas.kral at email.cz>

More information about the Oberon mailing list