Jump to content
McKay Development

JavaScript heap out of memory


Recommended Posts

<--- Last few GCs --->


[9212:00000230BE791410]   222793 ms: Mark-sweep 1416.0 (1509.0) -> 1416.0 (1493.0) MB, 908.0 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 908 ms) last resort
[9212:00000230BE791410]   223709 ms: Mark-sweep 1416.0 (1493.0) -> 1416.0 (1493.0) MB, 915.3 / 0.0 ms  last resort




<--- JS stacktrace --->


==== JS stack trace =========================================


Security context: 000002048E91CEA9 <JSObject>
    1: new constructor(aka EconItem) [C:\Users\*****\Documents\*********\*********\node_modules\steam-tradeoffer-manager\lib\classes\EconItem.js:~5] [pc=0000033EC5C265F2](this=000001FA21AD43E1 <EconItem map = 000001340AAE4441>,item=000003D861277141 <Object map = 00000127A0FEE2B9>)
    4: /* anonymous */(aka /* anonymous */) [C:\Users\*********\Documents\*********\*********\node_modules\steam-tradeof...


FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I have no idea why this is happening. Started about two-three days ago.

Edited by TheGoldenPotato
Link to comment
Share on other sites

Memory leak. You probably fucked up an infinite/recursive call stack somewhere that keeps adding, NodeJS itself has a call stack size limit. I can't remember the number off the top of my head but it is kinda low, you can manually raise it somehow if you need to. My own script barely takes ~80MB of RAM and it is mainly because I don't run it as a daemon, its the only thing I have running on a dedicated machine so I choose not to.

Link to comment
Share on other sites

Well I found the problem. My code misused Steam-TradeOffer-Manager/lib/assets.js . It somehow just keeps on running the code at line 46, which is 

		for (let i in cache[key]) {
			if (cache[key].hasOwnProperty(i)) {
				item[i] = cache[key][i];
			}
		}

It just kept on running it until my program reached around 1600-1800MB in RAM usage, and then crashed. I kinda makeshift fixed it, by doing so with the code.

TradeOfferManager.prototype._mapItemsToDescriptions = function(appid, contextid, items) {
	var cache = this._assetCache;

	if (!(items instanceof Array)) {
		items = Object.keys(items).map(key => items[key]);
	}

	return items.map((item) => {
		item.appid = appid || item.appid;
		item.contextid = contextid || item.contextid;

		var key = `${item.appid}_${item.classid}_${item.instanceid || '0'}`;
		if (!cache[key]) {
			// This item isn't in our description cache
			return new EconItem(item);
		}
/*
		for (let i in cache[key]) {
			if (cache[key].hasOwnProperty(i)) {
				item[i] = cache[key][i];
			}
		} 
*/
		return new EconItem(item);
	});
};

The program now runs at around 200MB instead of 500MB and then randomly peaking to godly amounts.

Edited by TheGoldenPotato
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...