Skip to content

[copy_gc & mark_sweep] Developer Documentation

Bryan Loh edited this page Apr 22, 2021 · 1 revision

This module is a series of memory management visualisation: copy_gc and mark_sweep written by developer Violin Yap.

Documentation

Refer to API documentation for copy_gc here. Refer to API documentation for mark_sweep here.

Before you start

  1. Learn more about Source Modules here.
  2. Make sure you have some knowledge in React and Typescript.
  3. Note that this visualisation is based on our own implementation of memory management methods.
  4. Have fun!

File Structure

All functions are stored within src/bundles/copy_gc or src/bundles/mark_sweep while TSX part are stored in src/tabs/CopyGC or src/tabs/MarkSweep. The folders contains the following files (same for both mark_sweep and copy_gc:

Bundles

  1. index.ts - Contains all the function and API used within the scope of the module
  2. type.ts - Contains the types defined within the module

Tabs

  1. index.tsx - Contains all the TSX and React part of the implementation.
  2. style.tsx - Contains color declaration that is used within the module.

Mechanism

This applies for both copy_gc and mark_sweep.

  1. The API can be called from Source Academy Playground if it is exported in function export default function mark_sweep() (or copy_gc) located at the bottom of index.ts
  2. index.tsx can 'communicate' with index.ts through init() function in index.ts that will pass its returned value through debuggerContext in index.tsx once the function is invoked in the running Source program.
  3. A tab will show if the user import copy_gc or mark_sweep.
  4. Memory layout will only be shown after the user successfully invoke initialize_memory() function.

Future Enhancements

These modules are built as part of CS4215 Programming Language Implementation project. To leverage on the implementation, here are some advancements that can be done:

  1. Viewing memory content of each node and also its children.
  2. Customisable and more generalised methods. We haven't get the chance to try and test out our visualisation with other way of Stop and Copy and Mark and Sweep garbage collection implementation so this can be a further exploration for the next project.
  3. More exception messages and error handling.
  4. Customisable color choice and more! You can explore the code to find out.
Clone this wiki locally