AOSSIE-Org / AOSSIE-Org/Ell-ena
BUG:[windows] Memory leak in WindowClassRegistrar singleton
- Lingua principale
- Dart
- Stelle
- 54
- Fork
- 110
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
### Is there an existing issue for this?
- [x] I have searched the existing issues
### What happened?
**Issue Overview**
WindowClassRegistrar::GetInstance() uses new to allocate memory but never calls delete, causing a memory leak. The destructor is never invoked, and window class registration cleanup never occurs.
**File**: windows/runner/win32_window.cpp
**Steps to Reproduce**
1. Create a new Flutter Windows project
2. Build and run the application (debug or release mode)
3. Close the application
4. Monitor memory usage with tools like Dr Memory or Visual Studio Diagnostic Tools
**Expected Behavior**
No memory leak; all allocated resources are properly cleaned up when the application exits or when the window class is unregistered.
**Actual Behavior**
Memory allocated by `new WindowClassRegistrar()` persists after application shutdown. While the leak is small (one instance per process), it violates C++ best practices and can accumulate in long-running sessions.
**Root Cause**
cpp
static WindowClassRegistrar* GetInstance() {
if (!instance_) {
instance_ = new WindowClassRegistrar(); // BUG: Never deleted
}
return instance_;
}
### Record
- [x] I agree to follow this project's Code of Conduct
- [x] I want to work on this issue
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.