Bob/leakTests
Bobby Lucero 3138f6fb92 Various changes, again. Updated extension. Added classes, super, this, polymorphism.
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
2025-08-10 22:44:46 -04:00
..
leaktest_builtin.bob Various changes, again. Updated extension. Added classes, super, this, polymorphism. 2025-08-10 22:44:46 -04:00
leaktest_collections.bob Various changes, again. Updated extension. Added classes, super, this, polymorphism. 2025-08-10 22:44:46 -04:00
leaktest_functions.bob Various changes, again. Updated extension. Added classes, super, this, polymorphism. 2025-08-10 22:44:46 -04:00
leaktest_loops.bob Various changes, again. Updated extension. Added classes, super, this, polymorphism. 2025-08-10 22:44:46 -04:00
leaktest_mixed.bob Various changes, again. Updated extension. Added classes, super, this, polymorphism. 2025-08-10 22:44:46 -04:00
README.md Property Expression, Fixed memory leaks 2025-08-08 19:03:49 -04:00

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:

  1. Memory should increase during object creation phases
  2. Memory should decrease significantly when objects are cleared (set to none, [], different types, etc.)
  3. Memory should return close to baseline after each test section
  4. 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, or ps 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.