Runtime: add method dispatch for array/string/dict/number (.len, .push, .pop, .keys, .values, .has, .toInt) Stdlib: delete global len/push/pop/keys/values/has Tests/docs/examples: migrate to method style; add tests/test_builtin_methods_style.bob All tests pass Breaking: global len/push/pop/keys/values/has removed; use methods instead Parser/AST: add class/extends/extension/super, field initializers Runtime: shared methods with this injection; classParents/classTemplates; super resolution; ownerClass/currentClass; extension lookup order Builtins: method dispatch for array/string/dict/number (.len/.push/.pop/.keys/.values/.has/.toInt); remove global forms Tests/docs/examples: add/refresh for classes, inheritance, super, polymorphism; migrate to method style; all tests pass VS Code extension: update grammar/readme/snippets for new features |
||
|---|---|---|
| .. | ||
| leaktest_builtin.bob | ||
| leaktest_collections.bob | ||
| leaktest_functions.bob | ||
| leaktest_loops.bob | ||
| leaktest_mixed.bob | ||
| README.md | ||
Bob Memory Leak Test Suite
This directory contains comprehensive memory leak tests for the Bob programming language. Each test file focuses on different scenarios that could potentially cause memory leaks.
Test Files
leaktest_functions.bob
Tests function-related memory scenarios:
- Recursive function closures
- Function factories (functions returning functions)
- Deep function nesting
- Circular function references
- Expected behavior: Memory should be freed when functions are cleared
leaktest_collections.bob
Tests collection (arrays/dictionaries) memory scenarios:
- Large nested arrays
- Large nested dictionaries
- Mixed array/dict structures
- Self-referencing structures
- Large string collections
- Expected behavior: Collections should be properly freed when reassigned
leaktest_mixed.bob
Tests mixed type scenarios and edge cases:
- Functions capturing collections
- Collections containing functions and mixed types
- Dynamic property assignment patterns
- Type reassignment chains
- Rapid allocation/deallocation cycles
- Expected behavior: Memory should be freed regardless of type mixing
leaktest_loops.bob
Tests memory behavior in loops and repetitive operations:
- Nested loop allocation
- While loop accumulation
- Variable reassignment in loops
- Do-while function creation
- Complex loop control flow
- Memory churn tests
- Expected behavior: Loop-created objects should be freed when variables are reassigned
leaktest_builtin.bob
Tests builtin function and stdlib memory behavior:
- Heavy string operations
- Type conversion stress tests
- Array/Dict builtin operations
- Eval function stress tests
- File I/O operations
- Random number generation
- Expected behavior: Builtin operations should not leak memory
How to Run Tests
Run each test individually and monitor memory usage:
# Monitor memory before, during, and after each test
./build-ninja/bin/bob leakTests/leaktest_functions.bob
./build-ninja/bin/bob leakTests/leaktest_collections.bob
./build-ninja/bin/bob leakTests/leaktest_mixed.bob
./build-ninja/bin/bob leakTests/leaktest_loops.bob
./build-ninja/bin/bob leakTests/leaktest_builtin.bob
Expected Behavior
After the memory leak fixes:
- Memory should increase during object creation phases
- Memory should decrease significantly when objects are cleared (set to
none,[], different types, etc.) - Memory should return close to baseline after each test section
- No gradual memory increase across multiple test cycles
Memory Monitoring
Use system tools to monitor memory:
- macOS: Activity Monitor or
top -pid $(pgrep bob) - Linux:
top,htop, orps aux | grep bob - Windows: Task Manager or Process Monitor
Look for:
- Memory spikes during creation phases ✅ Expected
- Memory drops after "cleared" messages ✅ Expected
- Memory staying high after clearing ❌ Potential leak
- Gradual increase across test cycles ❌ Potential leak
Test Scenarios Covered
- Object Types: Functions, Arrays, Dictionaries, Strings, Numbers, Booleans
- Memory Patterns: Allocation, Deallocation, Reassignment, Type Changes
- Edge Cases: Circular references, Deep nesting, Self-references, Mixed types
- Operations: Loops, Builtin functions, File I/O, Type conversions
- Cleanup Triggers: Setting to
none,[],{}, different types, string values
This comprehensive test suite should help identify any remaining memory leak scenarios in the Bob interpreter.