Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@3urobeat
Copy link

@3urobeat 3urobeat commented Jun 26, 2023

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 jobs object.
I added a type property to every jobs entry which stores the EMsg value 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

if (k.type && [ EMsg.ClientPICSChangesSinceRequest, EMsg.ClientPICSProductInfoRequest, EMsg.ClientPICSAccessTokenRequest ].includes(k.type)) {
delete this._jobs[e];
clearTimeout(this._jobCleanupTimers[e]);
delete this._jobCleanupTimers[e];
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause any outstanding getProductChanges, getProductInfo, or getProductAccessToken requests to time out, which isn't ideal.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@DoctorMcKay
Copy link
Owner

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.

@3urobeat
Copy link
Author

3urobeat commented Jun 27, 2023

If there is a better way of determining the owned apps then I'll look into it, thanks
But I still think having a function to clear the pics cache if needed would be a good feature

Edit: I completely overlooked that getUserOwnedApps() exists, does the job and doesn't need the picsCache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.