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]
#preflight 646f8f135b484acfee4932fb
[Backout] - CL25597666
#fyi zack.neyland
Original CL Desc
-----------------------------------------------------------------
Reverting CL 25577637, it's is blocking Mac editor from opening entirely.
The failure is coming dyld with the following: "could not create thread local variables pthread key". This occurs during plugin loading.
#preflight 646d775d1b241f0748e75e95
#jira UE-186763
[CL 25623686 by Andriy Tylychko in ue5-main branch]
The failure is coming dyld with the following: "could not create thread local variables pthread key". This occurs during plugin loading.
#preflight 646d775d1b241f0748e75e95
#jira UE-186763
[CL 25597666 by zack neyland 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]
* added a thread-safe (locked) delegates variant
* refactored and enabled by default race detection for the original not thread-safe version
* added "not thread-safe not checked" variant for rare cases where race detection doesn't work or it's a known case of a race
#rb steve.robb, francis.hurteau, danny.couture
#preflight 646b9f4d576becd7b53f674c
[CL 25577637 by Andriy Tylychko in ue5-main branch]