Add clearPicsCache function to reduce memory usage and store job types#444
Add clearPicsCache function to reduce memory usage and store job types#4443urobeat wants to merge 4 commits intoDoctorMcKay:masterfrom
Conversation
| if (k.type && [ EMsg.ClientPICSChangesSinceRequest, EMsg.ClientPICSProductInfoRequest, EMsg.ClientPICSAccessTokenRequest ].includes(k.type)) { | ||
| delete this._jobs[e]; | ||
| clearTimeout(this._jobCleanupTimers[e]); | ||
| delete this._jobCleanupTimers[e]; |
There was a problem hiding this comment.
This will cause any outstanding getProductChanges, getProductInfo, or getProductAccessToken requests to time out, which isn't ideal.
There was a problem hiding this comment.
Is that of great concern if the user clears the cache manually and intentionally?
I'd assume any related pending requests aren't needed then anymore. This would be something worth noting in the README and JsDoc though
|
If your use-case is simply that you need to know which apps you own, I'd rather come up with a better way of determining that without needing to enable the entire pics cache. |
|
If there is a better way of determining the owned apps then I'll look into it, thanks Edit: I completely overlooked that |
This PR adds a clearPicsCache() function to reduce memory usage if content is not needed anymore.
In order for the garbage collector to instantly free the memory being used we need to filter the
jobsobject.I added a
typeproperty to everyjobsentry which stores theEMsgvalue of the associated request. This allows us to only filter PICS related entries instead of needing to nuke the whole object.Related forum thread:
https://dev.doctormckay.com/topic/4476-advice-needed-on-clearing-picscache-im-struggling-with-ram-usage/
Note: I updated the documentation but I didn't fill out the required version as I don't know which version number you'll choose