[Oberon] PO2013 - Show Heap Blocks
Tomas Kral
thomas.kral at email.cz
Wed Jun 17 21:54:50 CEST 2020
Hi Andreas,
It seems, I do not receive your posts, although they appear on
https://lists.inf.ethz.ch/
PROCEDURE GenericScan*();
...
IF mark > 0 THEN (*marked*) SYSTEM.PUT(p+4, 0);
...
INC(p, size)
UNTIL p >= heapLim
END GenericScan;
In your code above, unmark with 0 [PUT(p+4, 0)], while for freed put -1.
0 - to be freed, -1 freed, >0 still used?
Can we actually do heap scan without Kernel.Mark()?
I attempted in this code, which does not really see any mark >0 blocks.
MODULE Heap; (*TK 14.6.2020 show heap blocks*)
IMPORT S := SYSTEM, Out;
VAR heapOrg, MemLim, heapLim: INTEGER;
PROCEDURE Show*;
VAR p, q, mark, tag, size, used, free: LONGINT;
BEGIN p := heapOrg; used := 0; free := 0;
REPEAT S.GET(p+4, mark); (*mark: 0 to be freed, -1 freed, >0 still used*)
IF mark = -1 THEN S.GET(p, size)
ELSE S.GET(p, tag); S.GET(tag, size) END ;
IF (*size = 14H*) (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 (*** WHY this reports a free block??? ***)
END ;
IF mark > 0 THEN INC(used, size) (*none*)
ELSIF mark = 0 THEN INC(free, size)
ELSIF mark = -1 THEN INC(free, size) END ;
INC(p, size)
UNTIL p >= heapLim(*-30000H*) ;
Out.Hex(used); Out.Hex(free);Out.Ln
END Show;
BEGIN S.GET(12, MemLim); S.GET(24, heapOrg); heapLim := MemLim
END Heap.
Heap.Show
--
Tomas Kral <thomas.kral at email.cz>
More information about the Oberon
mailing list