fix(recorder): Fix memory leak of RecorderClass::m_crcInfo#2713
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/Common/Recorder.h | CRCInfo nested class added to protected section; m_crcInfo changed from pointer to value member; includes are intact for the existing build system |
| Generals/Code/GameEngine/Source/Common/Recorder.cpp | CRCInfo implementation moved to qualified RecorderClass::CRCInfo:: methods; default constructor added; all pointer dereferences converted to value access; NEW allocation replaced with value assignment |
| GeneralsMD/Code/GameEngine/Include/Common/Recorder.h | Identical refactor to the Generals header; clean and consistent with its counterpart |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Identical refactor to the Generals .cpp; all call sites updated, no remaining raw pointer usage |
Sequence Diagram
sequenceDiagram
participant RC as RecorderClass
participant CI as CRCInfo (value member)
Note over RC,CI: Before this PR: CRCInfo* (heap-allocated, never deleted)
Note over RC,CI: After this PR: CRCInfo (value member, auto-managed lifetime)
RC->>CI: RecorderClass() — default CRCInfo() constructed in-place
RC->>CI: "playbackFile() — m_crcInfo = CRCInfo(playerIndex, isMultiplayer)"
loop Replay frames
RC->>CI: "handleCRCMessage(fromPlayback=true) → addCRC(val)"
RC->>CI: "handleCRCMessage(fromPlayback=false) → readCRC() / sawCRCMismatch()"
end
RC->>CI: ~RecorderClass() — CRCInfo destructor called automatically
Reviews (7): Last reviewed commit: "Moved 'm_crcInfo'." | Re-trigger Greptile
282478b to
c5e3079
Compare
xezon
left a comment
There was a problem hiding this comment.
Looking good. Needs replicate to Generals.
e99381e to
82efc2a
Compare
This avoids an unnecessary dynamic memory allocation and fixes a memory leak.
…aks to the latter.
|
Rebased to include the fix for the CI Replay checker. |
This PR fixes a memory leak for
RecorderClass::m_crcInfo. I decided to fix this one by not allocating theCRCInfoobject dynamically. This did require a larger change of moving the class to the header, though.See commits for clean diffs.
TODO: