I've reviewed all code using async requests and we had multiple places incorrectly handling the stat: some placed failed to decrease the counter, while others would decrease it when they shouldn't. The main cause was the fact that when we create an async request and pass nullptr as the target memory, the request allocates the memory itself and increases the STAT_AsyncFileMemory. However, when we call GetReadResults() on such requests, the responsibility is on the caller to balance the calls and decrease the stat, which is not very obvious and leads to the mentioned bugs. On top of that, when we call GetReadResults() we may not have the knowledge as to whether the returned memory was allocated by the request or not (which may affect whether we should touch the stat at all).
Resolved by adding IAsyncReadRequest::ReleaseMemoryOwnershipImpl member, which may be used by request implementations to do the proper clean up (balance the stat). This way requests take the full responsibility for their changes and users of the requests don't need to know their implementation details.
#preflight none
#rb Patrick.Laflamme
#jira UE-185064
[CL 25664733 by Wojciech Krywult in ue5-main branch]
[FYI] Maxime.Mercier
Original CL Desc
-----------------------------------------------------------------
Fix reference replacement of set not being rehash when key are replaced
#rb [at]Steve.Robb
#preflight 646e2d4d1134ffac70a5d655
[CL 25644174 by maxime mercier in ue5-main branch]
#rb Johan.Torp
#jira none
#rnx
#preflight 646c890b1b241f0748712b58
*** Garbage Collection
- Change 'TimeLimit' parameters in FAsyncPurge to double as the value is a double before being passed in and is compred to other doubles inside of the ::Tick methods anyway.
- FWorkCoordinator constructor was doing pointer arithmetic to find the array index. Since we know the array uses int32 for the size (TArrayView) we can just use UE_PTRDIFF_TO_INT32 for the cast.
*** Garbage Collection Schema
- Used IntCastChecked in places where we are going from larger types to smaller ones to fit in with the style of the rest of the code file (INtCastChecked is being used elsewhere here for similar cases)
- Store the size of memory to be allocated in a SIZE_T, the return type of Align and the type that FMemory::Malloc takes.
[CL 25580726 by paul chipchase in ue5-main branch]
The code for parsing a view of the ZenPackageSummary has been extracted from AsyncLoading2.cpp into a private h/cpp and is possible to use from the header diffing code when printing out detailed diffs, but is not used yet.
#rb matt.peters
#rb pj.kack
#jira UE-175237
[CL 25549055 by zousar shaker in ue5-main branch]