Skip to content

Commit d8db5e8

Browse files
committed
Fix memory leak
1 parent 2e2b4a3 commit d8db5e8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Client/game_sa/CStreamingSA.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "CModelInfoSA.h"
1616
#include "Fileapi.h"
1717
#include "processthreadsapi.h"
18+
#include "CGameSA.h"
1819

1920
extern CCoreInterface* g_pCore;
2021

@@ -334,6 +335,14 @@ void CStreamingSA::SetStreamingInfo(uint modelid, unsigned char usStreamID, uint
334335
{
335336
CStreamingInfo* pItemInfo = GetStreamingInfo(modelid);
336337

338+
// We remove the existing RwObject because, after switching the archive, the streamer will load a new one.
339+
// ReInit doesn’t delete all RwObjects unless certain conditions are met.
340+
// In this case, we must force-remove the RwObject from memory, because it is no longer used,
341+
// and due to the archive change the streamer no longer detects it and therefore won’t delete it.
342+
// As a result, a memory leak occurs after every call to engineImageLinkDFF.
343+
if (CModelInfo* modelInfo = g_pCore->GetGame()->GetModelInfo(modelid); modelInfo->GetRwObject())
344+
RemoveModel(modelid);
345+
337346
// Change nextInImg field for prev model
338347
for (CStreamingInfo& info : ms_aInfoForModel)
339348
{

0 commit comments

Comments
 (0)