GSoC/GCI Archive
Google Code-in 2011 Parrot Foundation

Add --mem-limit commandline option to Parrot

completed by: Pawel Nowak

mentors: Andrew Whitworth

Task Description

Parrot Ticket #67 describes a long-standing TODO item for Parrot. We would like the ability to be able to specify the maximum total amount of allocated memory on the commandline. Playing with GC internals can be extremely difficult, but setting up the necessary mechanisms to parse a command-line option and make that data available in the interpreter is a good task. This task requires many steps:

  • Add a "gc_max_allocate" member (Parrot_Int type) to the Parrot_Init_Args structure in include/parrot/api.h.
  • Add in a new --mem-limit=X option to the commandline. Parse the option in frontend/parrot2/parrot.c, following existing example code (if you need help understanding the getopt function, ask for help). Parse the value and add it to the Parrot_Init_Args structure that is created.
  • Add a similar member to the Parrot_GC_Init_Args structure in include/parrot/gc_api.h.
  • In the file src/embed/api.c Make sure to copy the value from the Parrot_Init_Args structure to the Parrot_GC_Init_Args structure in the function Parrot_api_make_interpreter.
  • Add a similar member to the MarkSweep_GC structure in src/gc/gc_gms.c. In the same file, the function Parrot_gc_gms_init, make sure to copy the value from "args" to "self".

Once this value has been parsed and passed to the GC subsystem, we will be able to integrate it into the GC logic.

Steps To Complete This Task

  1. Create a fork of parrot.git on
  2. Follow all the steps listed above.
  3. Build parrot and run it's test suite (make fulltest) to verify that things still work
  4. Create a Github pull request (button on the upper right of your fork) to have your changes incorporated into the master repository


  1. The ability to force a maximum allocation size is extremely important for embedded devices and other memory-contained environments where Parrot might operate.


  1. C Programming Language

Additional Links