| 1 | According to reports, Microsoft's XNA framework uses the amount of memory allocated as a guide to run full GC. Every time they've allocated a megabyte, they run the GC. We can do something similar. |
| 2 | |
| 3 | Modify the "get more objects" function to: |
| 4 | |
| 5 | * check the amount of memory allocated since the last GC run |
| 6 | * if it's less than a threshold value (defined as a C constant), allocate a new pool |
| 7 | * if it meets or exceeds the threshold, run a full GC |
| 8 | |
| 9 | Modify the "allocate a new pool" function to: |
| 10 | |
| 11 | * add the size of the new pool to the "memory allocated since last full GC" |
| 12 | |
| 13 | Modify the "run full GC" function to: |
| 14 | |
| 15 | * reset the "memory allocated since last full GC" counter to zero |
| 16 | |
| 17 | Find an appropriate storage location for the "memory allocated since..." counter in the GC structure somewhere. |
| 18 | |
| 19 | Depending on memory growth, we may need also to set a maximum memory size for Parrot to avoid unbounded growth... but that relies on us being able to detect when the internal memory overhead (highly recursive calls, for example) is significant. |