[Oberon] SystemV- Heap + Module Space

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Sun Dec 30 21:11:48 CET 2018


   > How can I compact unused module space after clean up, or is it really needed?

One small change you could introduce to your system is to change Modules.Mod ...

From…

    PROCEDURE Free*(name: ARRAY OF CHAR);
      VAR mod, imp: Module; p, q: INTEGER;
    BEGIN mod := root; res := 0;
      WHILE (mod # NIL) & (mod.name # name) DO mod := mod.next END ;
      IF mod # NIL THEN
        IF mod.refcnt = 0 THEN
          mod.name[0] := 0X; p := mod.imp; q := mod.cmd;
          WHILE p < q DO SYSTEM.GET(p, imp); DEC(imp.refcnt); INC(p, 4) END ;
        ELSE res := 1
        END
      END
    END Free;

To…

    PROCEDURE Free*(name: ARRAY OF CHAR);
      VAR mod, imp: Module; p, q: INTEGER;
    BEGIN mod := root; res := 0;
      WHILE (mod # NIL) & (mod.name # name) DO mod := mod.next END ;
      IF mod # NIL THEN
        IF mod.refcnt = 0 THEN
          mod.name[0] := 0X; p := mod.imp; q := mod.cmd;
          WHILE p < q DO SYSTEM.GET(p, imp); DEC(imp.refcnt); INC(p, 4) END ;
          IF mod = root THEN (*increase size of available module space*)
            p := mod.size; mod := mod.next;
            WHILE (mod # NIL) & (mod.name[0] = 0X) DO INC(p, mod.size); mod := mod.next END ;
            AllocPtr := AllocPtr - p; root := mod
          END
        ELSE res := 1
        END
      END
    END Free;

and rebuild the system …

    ORP.Compile Modules.Mod ~
    Boot.Link Modules ~
    Boot.Load Modules.bin ~

This small change will automatically clean up unused module blocks at the “end*
of the module list (i.e. those shown first by System.ShowModules) when such
modules are unloaded, but not those “in the middle”.

You could also try to compact those in the middle and make one big unused module
block out of them whenever possible, but this would be overkill (probably).







More information about the Oberon mailing list