fix(memory): Fix memory leak for RecorderClass::m_crcInfo#2713
fix(memory): Fix memory leak for RecorderClass::m_crcInfo#2713Caball009 wants to merge 8 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Include/Common/Recorder.h | Promotes CRCInfo to nested class of RecorderClass; changes m_crcInfo from CRCInfo* to CRCInfo value member; adds default constructor declaration. |
| Generals/Code/GameEngine/Source/Common/Recorder.cpp | Adds default constructor for CRCInfo; moves CRCInfo implementation to RecorderClass::CRCInfo scope; removes file-local class definition; converts all pointer accesses to value accesses; replaces NEW with copy-assignment. |
| GeneralsMD/Code/GameEngine/Include/Common/Recorder.h | Mirror of Generals header change — same CRCInfo nesting and value-member conversion. |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Mirror of Generals source change — same constructor additions, class removal, and pointer-to-value conversion for m_crcInfo. |
Reviews (5): Last reviewed commit: "Tweaked 'CRCInfo' TSH comment." | Re-trigger Greptile
282478b to
c5e3079
Compare
This avoids an unnecessary dynamic memory allocation and fixes a memory leak.
xezon
left a comment
There was a problem hiding this comment.
Looking good. Needs replicate to Generals.
| // compare those with the local gamestate, they wouldn't sync up. | ||
| // So, in order to fix this, we need to queue up our local CRCs, | ||
| // so that we can check it with the crc messages that come later. | ||
| // This class is basically that queue. |
There was a problem hiding this comment.
While at it, perhaps compact the format of the massive comment a bit.
There was a problem hiding this comment.
Btw, I did not mean to rewrite it shorter, just compacting the format of the sentences to save a bit space.
There was a problem hiding this comment.
Oops. You want the original comment back?
There was a problem hiding this comment.
I asked Chat Gippy to rewrite this more densely and it wrote this:
// CRC overview:
// Each peer periodically computes a CRC from its local game state and broadcasts it to all peers, including itself,
// to verify synchronization. CRC messages are received a few frames later in network games to avoid stalling every
// frame while waiting for all peers. This works because all peers compare the same received CRCs on the same frame.
//
// Replays are different: recorded CRC messages appear on the frame they were originally received, so directly
// comparing them against the current local state would mismatch. To handle this, local CRCs must be queued until the
// corresponding replay CRC messages arrive. This class implements that queue.Maybe that also works?
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: