Skip to content

Performance improvements and enhanced error handling#14

Open
RamiAhmed wants to merge 4 commits intoaptabase:mainfrom
RamiAhmed:main
Open

Performance improvements and enhanced error handling#14
RamiAhmed wants to merge 4 commits intoaptabase:mainfrom
RamiAhmed:main

Conversation

@RamiAhmed
Copy link

Summary

Performance optimizations and improved error handling for production Unity applications.

Changes

  • Memory optimization: Use ListPool and DictionaryPool to reduce GC allocations
  • Async improvements: Flush() now returns Task with CancellationToken support throughout the call chain
  • Better error handling: Comprehensive HTTP status code handling with actionable error messages

Technical Details

// Before: new allocations every time
var props = new Dictionary<string, object>();

// After: pooled allocations
var props = DictionaryPool<string, object>.Get();
// ... use ...
DictionaryPool<string, object>.Release(props);

// Cancellation support
await Aptabase.Flush(cancellationToken);

Testing

✅ Verified memory reduction via Unity Profiler
✅ Tested cancellation token propagation
✅ 100% backward compatible - no breaking changes

Benefits

  • Reduced GC spikes in high-frequency event tracking
  • Better async/await patterns for Unity lifecycle
  • Clear, actionable error messages for debugging
  • Improved production readiness

RamiAhmed and others added 4 commits June 17, 2025 13:50
use ListPool and DictionaryPool to avoid unnecessary memory allocations + automatic code cleanup + cancellation handled all the way through to WebRequestHelper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant