Yeezy Posted May 20, 2023 Report Share Posted May 20, 2023 (edited) There's a possible memory leak in comps/friends.js or comps/familysharing.js (edit: I could be wrong about where the leak is) (please check my attached image) The issue is rare and I'm unable to actively reproduce it yet, However it happens every 7 to 14 days after the App has been running for a while with 150~ instances of steamUser. (no memory leak until it happens) I will update this thread as I find more useful details to go on. the only part of my code which interacts with the steamUserFriends steamUser.chat.on('friendMessage', async (message) => { if (config.autoReply) { if (!client.autoReplyRecipients.includes(message.steamid_friend.getSteamID64())) { client.autoReplyRecipients.push(message.steamid_friend.getSteamID64()) steamUser.chat.sendFriendMessage(message.steamid_friend, config.autoReply) setTimeout((removeSteamId) => { client.autoReplyRecipients = client.autoReplyRecipients.filter(steamId => steamId !== removeSteamId) }, 60000, message.steamid_friend.getSteamID64()) } } }) steamUser.on('friendRelationship', (sid, relationship) => { if (config.autoFriend && relationship == SteamUser.EFriendRelationship.RequestRecipient) { steamUser.addFriend(sid) } }) Edited May 20, 2023 by Yeezy Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 20, 2023 Author Report Share Posted May 20, 2023 15 May, Heapsnapshot size: 71 MB (no leak) 16 May, Heapsnapshot size: 1.85 GB Should I log/trace all locations where a new SteamID gets created (inside the node-steam-user lib) and see if that leads me anywhere? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 20, 2023 Report Share Posted May 20, 2023 Between your two screenshots, it kinda looks to me like g_ProcessPersonaSemaphore is somehow hanging at some point. The semaphore is backed by a linked list, and I see a lot of prev pointers in your OP screenshot. I don't really see why it would hang though, all code paths end in releasing the lock. That would also cause SteamID objects to pile up, as you're seeing in your heap snapshot. In any case, try 4.28.4 and see if that fixes things for you. Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 21, 2023 Author Report Share Posted May 21, 2023 14 hours ago, Dr. McKay said: Between your two screenshots, it kinda looks to me like g_ProcessPersonaSemaphore is somehow hanging at some point. The semaphore is backed by a linked list, and I see a lot of prev pointers in your OP screenshot. I don't really see why it would hang though, all code paths end in releasing the lock. That would also cause SteamID objects to pile up, as you're seeing in your heap snapshot. In any case, try 4.28.4 and see if that fixes things for you. Thank you, I'll try the update and let you know Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 23, 2023 Author Report Share Posted May 23, 2023 Node: v16.14 [email protected] Should I run node LTS 18.x and see if that resolves anything? or log a specific variable/obj count inside the module to see whats happening? I took a heap snapshot and will be checking it, I'll post an update if I find anything Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 23, 2023 Author Report Share Posted May 23, 2023 I don't have a snapshot from when the server was initialized but I have one from a server that was started at the exact same time and has the same amount of steamUser instances on it. If there's anything specific you'd like me to try and/or look at please let me know. no leak: leaked: Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 23, 2023 Author Report Share Posted May 23, 2023 Seems like I acted too soon, but its still weird behavior Ignore the RSS size, its caused by the heapsnapshot not being released properly (https://github.com/nodejs/node/issues/44027) Quote Link to comment Share on other sites More sharing options...
Yeezy Posted May 31, 2023 Author Report Share Posted May 31, 2023 4.28.4 still leaked memory unfortunately. Running a test currently with the following handlers disabled: EMsg.ClientPersonaState EMsg.ClientClanState EMsg.ClientFriendsList It's been looking good so far no memory leak yet (running for 4+ days now) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.