ObjMem.st
changeset 375 e5019c22f40e
parent 370 20f04d9b371b
child 379 5b5a130ccd09
equal deleted inserted replaced
374:7eb5bedfaa1c 375:e5019c22f40e
    32 
    32 
    33 ObjectMemory comment:'
    33 ObjectMemory comment:'
    34 COPYRIGHT (c) 1992 by Claus Gittinger
    34 COPYRIGHT (c) 1992 by Claus Gittinger
    35 	     All Rights Reserved
    35 	     All Rights Reserved
    36 
    36 
    37 $Header: /cvs/stx/stx/libbasic/Attic/ObjMem.st,v 1.48 1995-08-03 01:15:54 claus Exp $
    37 $Header: /cvs/stx/stx/libbasic/Attic/ObjMem.st,v 1.49 1995-08-08 00:47:48 claus Exp $
    38 '!
    38 '!
    39 
    39 
    40 !ObjectMemory class methodsFor:'documentation'!
    40 !ObjectMemory class methodsFor:'documentation'!
    41 
    41 
    42 copyright
    42 copyright
    53 "
    53 "
    54 !
    54 !
    55 
    55 
    56 version
    56 version
    57 "
    57 "
    58 $Header: /cvs/stx/stx/libbasic/Attic/ObjMem.st,v 1.48 1995-08-03 01:15:54 claus Exp $
    58 $Header: /cvs/stx/stx/libbasic/Attic/ObjMem.st,v 1.49 1995-08-08 00:47:48 claus Exp $
    59 "
    59 "
    60 !
    60 !
    61 
    61 
    62 documentation
    62 documentation
    63 "
    63 "
   455      start to release object."
   455      start to release object."
   456 
   456 
   457     ^ LowSpaceSemaphore
   457     ^ LowSpaceSemaphore
   458 ! !
   458 ! !
   459 
   459 
       
   460 !ObjectMemory class methodsFor:'VM messages'!
       
   461 
       
   462 infoPrinting:aBoolean
       
   463     "turn on/off various informational printouts in the VM.
       
   464      For example, the GC activity messages are controlled by
       
   465      this flags setting.
       
   466      The default is true, since (currently) those messages
       
   467      are useful for ST/X developers."
       
   468 
       
   469 %{  /* NOCONTEXT */
       
   470     extern int __infoPrinting;
       
   471 
       
   472     __infoPrinting = (aBoolean == true);
       
   473 %}
       
   474 !
       
   475 
       
   476 infoPrinting
       
   477     "return true, if various informational printouts in the VM
       
   478      are turned on, false of off."
       
   479 
       
   480 %{  /* NOCONTEXT */
       
   481     extern int __infoPrinting;
       
   482 
       
   483     RETURN (__infoPrinting ? true : false);
       
   484 %}
       
   485 !
       
   486 
       
   487 debugPrinting:aBoolean
       
   488     "turn on/off various debug printouts in the VM
       
   489      in case of an error. For example, a double-notUnderstood
       
   490      leads to a VM context dump if debugPrinting is on.
       
   491      If off, those messages are suppressed.
       
   492      The default is on, since these messages are only printed for
       
   493      severe errors."
       
   494 
       
   495 %{  /* NOCONTEXT */
       
   496     extern int __debugPrinting;
       
   497 
       
   498     __debugPrinting = (aBoolean == true);
       
   499 %}
       
   500 !
       
   501 
       
   502 debugPrinting
       
   503     "return true, if various debug printouts in the VM
       
   504      are turned on, false of off."
       
   505 
       
   506 %{  /* NOCONTEXT */
       
   507     extern int __debugPrinting;
       
   508 
       
   509     RETURN (__debugPrinting ? true : false);
       
   510 %}
       
   511 ! !
       
   512 
   460 !ObjectMemory class methodsFor:'dependents access'!
   513 !ObjectMemory class methodsFor:'dependents access'!
   461 
   514 
   462 dependents
   515 dependents
   463     "return the colleciton of my dependents"
   516     "return the colleciton of my dependents"
   464 
   517 
  1457      ... continue - objects created above are now in oldSpace ...
  1510      ... continue - objects created above are now in oldSpace ...
  1458     "
  1511     "
  1459 !
  1512 !
  1460 
  1513 
  1461 garbageCollect
  1514 garbageCollect
       
  1515     "search for and free garbage in the oldSpace.
       
  1516      This can take a long time - especially, if paging is involved."
       
  1517 
       
  1518     "/ used to be 
       
  1519     "/    self compressingGarbageCollect 
       
  1520     "/ here; changed to default to markAndSweep
       
  1521 
       
  1522     self markAndSweep
       
  1523 
       
  1524     "
       
  1525      ObjectMemory garbageCollect
       
  1526     "
       
  1527 !
       
  1528 
       
  1529 compressingGarbageCollect
  1462     "search for and free garbage in the oldSpace (newSpace is cleaned automatically) 
  1530     "search for and free garbage in the oldSpace (newSpace is cleaned automatically) 
  1463      performing a COMPRESSING garbage collect.
  1531      performing a COMPRESSING garbage collect.
  1464      This can take a long time - especially, if paging is involved
  1532      This can take a long time - especially, if paging is involved
  1465      (when no paging is involved, its faster than I thought :-).
  1533      (when no paging is involved, its faster than I thought :-).
  1466      If no memory is available for the compress, or the system has been started with
  1534      If no memory is available for the compress, or the system has been started with
  1470 	__markAndSweep(__context);
  1538 	__markAndSweep(__context);
  1471     }
  1539     }
  1472 %}
  1540 %}
  1473 
  1541 
  1474     "
  1542     "
  1475      ObjectMemory garbageCollect
  1543      ObjectMemory compressingGarbageCollect
       
  1544     "
       
  1545 !
       
  1546 
       
  1547 markAndSweep
       
  1548     "mark/sweep garbage collector.
       
  1549      perform a full mark&sweep collect.
       
  1550      Warning: this may take some time and it is NOT interruptable.
       
  1551      If you want to do a collect from a background process, or have
       
  1552      other things to do, better use #incrementalGC which is interruptable."
       
  1553 %{
       
  1554     __markAndSweep(__context);
       
  1555 %}
       
  1556 
       
  1557     "
       
  1558      ObjectMemory markAndSweep
  1476     "
  1559     "
  1477 !
  1560 !
  1478 
  1561 
  1479 reclaimSymbols
  1562 reclaimSymbols
  1480     "reclaim unused symbols;
  1563     "reclaim unused symbols;
  1485 %{
  1568 %{
  1486     __reclaimSymbols(__context);
  1569     __reclaimSymbols(__context);
  1487 %}
  1570 %}
  1488     "
  1571     "
  1489      ObjectMemory reclaimSymbols
  1572      ObjectMemory reclaimSymbols
  1490     "
       
  1491 !
       
  1492 
       
  1493 markAndSweep
       
  1494     "mark/sweep garbage collector.
       
  1495      perform a full mark&sweep collect.
       
  1496      Warning: this may take some time and it is NOT interruptable.
       
  1497      If you want to do a collect from a background process, or have
       
  1498      other things to do, better use #incrementalGC which is interruptable."
       
  1499 %{
       
  1500     __markAndSweep(__context);
       
  1501 %}
       
  1502 
       
  1503     "
       
  1504      ObjectMemory markAndSweep
       
  1505     "
  1573     "
  1506 !
  1574 !
  1507 
  1575 
  1508 gcStep
  1576 gcStep
  1509     "one incremental garbage collect step.
  1577     "one incremental garbage collect step.
  1569     ].
  1637     ].
  1570     ^ done not
  1638     ^ done not
  1571 !
  1639 !
  1572 
  1640 
  1573 verboseGarbageCollect
  1641 verboseGarbageCollect
  1574     "perform a compessing garbage collect and show some informational
  1642     "perform a compressing garbage collect and show some informational
  1575      output on the Transcript"
  1643      output on the Transcript"
  1576 
  1644 
  1577     |nBytesBefore nReclaimed value unit|
  1645     |nBytesBefore nReclaimed value unit|
  1578 
  1646 
  1579     nBytesBefore := self oldSpaceUsed.
  1647     nBytesBefore := self oldSpaceUsed.
  1580     self garbageCollect.
  1648     self compressingGarbageCollect.
  1581     nReclaimed := nBytesBefore - self oldSpaceUsed.
  1649     nReclaimed := nBytesBefore - self oldSpaceUsed.
  1582     nReclaimed > 0 ifTrue:[
  1650     nReclaimed > 0 ifTrue:[
  1583 	nReclaimed > 1024 ifTrue:[
  1651 	nReclaimed > 1024 ifTrue:[
  1584 	    nReclaimed > (1024 * 1024) ifTrue:[
  1652 	    nReclaimed > (1024 * 1024) ifTrue:[
  1585 		value := nReclaimed // (1024 * 1024).
  1653 		value := nReclaimed // (1024 * 1024).
  2649 !
  2717 !
  2650 
  2718 
  2651 compactingGC
  2719 compactingGC
  2652     self garbageCollect
  2720     self garbageCollect
  2653 ! !
  2721 ! !
  2654