Created
November 22, 2013 02:09
-
-
Save quoll/7593630 to your computer and use it in GitHub Desktop.
Diff to scan the heap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gherkin b/gherkin | |
index 073e926..06211ba 100755 | |
--- a/gherkin | |
+++ b/gherkin | |
@@ -210,6 +210,20 @@ mark() { | |
done | |
} | |
+test_heap() { | |
+ local top | |
+ top=$((cons_ptr + 1)) | |
+ while [[ -z "${marks[${tag_marker}002${top}]}" ]] && ((top < cons_limit)); do | |
+ ((top++)) | |
+ done | |
+ if ((top < cons_limit)) ; then | |
+ echo "ERROR: Corrupted heap" | |
+ echo "Error at top + $((top - cons_ptr))" | |
+ else | |
+ echo "Clean heap" | |
+ fi | |
+} | |
+ | |
gc() { | |
echo "GC..." >&2 | |
IFS="$DEFAULT_IFS" | |
@@ -220,6 +234,7 @@ gc() { | |
while [[ -n "${marks[${tag_marker}002${cons_ptr}]}" ]]; do | |
unset marks["${tag_marker}002$((cons_ptr++))"] | |
done | |
+ test_heap | |
if [[ $cons_ptr == $cons_limit ]]; then | |
echo "expanding heap..." >&2 | |
cons_limit=$((cons_limit + heap_increment)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment