Maybe memory leak in inspector?

I honestly don’t know what is causing this.
I am using ES6 and wokring in Visual Studio Code,
When inspector is not called I can compile with this warning which is annoying, but things still work and i get what it says, the compiled file is large. Though that is odd as I am using tree shaking, and not really using much of anything, it does not seem to hurt anything and I am just developing so no big deal.
npm run-script build

> play-with-technology@0.0.1 build D:\Desktop\webProjects\pwt\web
> npx webpack --config webpack.prod.js

Hash: 5ca9dfae899cf476b1b2
Version: webpack 4.44.2
Time: 35930ms
Built at: 10/19/2020 10:21:21 PM
               Asset      Size  Chunks                          Chunk Names
    src/pwtEngine.js  3.05 MiB       0  [emitted]        [big]  main
src/pwtEngine.js.map  11.6 MiB       0  [emitted] [dev]         main
Entrypoint main [big] = src/pwtEngine.js src/pwtEngine.js.map
[19] ./node_modules/@babylonjs/core/Engines/Processors/shaderProcessor.js + 9 modules 27.6 KiB {0} [built]
     |    10 modules
[29] (webpack)/buildin/global.js 472 bytes {0} [built]
[30] ./src/index.ts + 852 modules 7.71 MiB {0} [built]
     | ./src/index.ts 1.93 KiB [built]
     | ./src/pwt.ts 1.13 KiB [built]
     | ./src/dataLoader.ts 6.83 KiB [built]
     | ./src/interface.ts 3.23 KiB [built]
     | ./src/world.ts 760 bytes [built]
     | ./src/camera.ts 1.13 KiB [built]
     | ./src/globalEnvironment.ts 2.59 KiB [built]
     |     + 846 hidden modules
    + 28 hidden modules

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
This can impact web performance.
Assets:
  src/pwtEngine.js (3.05 MiB)

WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
Entrypoints:
  main (3.05 MiB)
      src/pwtEngine.js


WARNING in webpack performance recommendations: 
You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.
For more info visit https://webpack.js.org/guides/code-splitting/

BUT when I include inspector in my project, I get critical error

npm run-script build

> play-with-technology@0.0.1 build D:\Desktop\webProjects\pwt\web
> npx webpack --config webpack.prod.js


<--- Last few GCs --->

[4388:0000020E48168FA0]    56259 ms: Scavenge 1372.4 (1422.7) -> 1371.7 (1423.2) MB, 2.7 / 0.0 ms  (average mu = 0.194, current mu = 0.145) allocation failure
[4388:0000020E48168FA0]    56264 ms: Scavenge 1372.6 (1423.2) -> 1372.1 (1423.7) MB, 3.0 / 0.0 ms  (average mu = 0.194, current mu = 0.145) allocation failure
[4388:0000020E48168FA0]    56269 ms: Scavenge 1372.8 (1423.7) -> 1372.6 (1425.2) MB, 2.9 / 0.0 ms  (average mu = 0.194, current mu = 0.145) allocation failure


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 0000010597F5C5C1]
Security context: 0x03af9719e6e9 <JSObject>
    1: new SourceNode [0000025B83D0CA79] [D:\Desktop\webProjects\pwt\web\node_modules\webpack-sources\node_modules\source-map\lib\source-node.js:~35] [pc=00000105986B11C0](this=0x034ad552f2d1 <SourceNode map = 0000001A5102ABB1>,aLine=85,aColumn=17,aSource=0x0262b1341041 <String[67]: ../../../../sourceES6/core/Materials/Node/nodeMaterialBuildState.ts>,aChun...     

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF69C71DD8A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
 2: 00007FF69C6F8886 node::MakeCallback+4534
 3: 00007FF69C6F9200 node_module_register+2032
 4: 00007FF69CA130DE v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF69CA1300F v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF69CBF9804 v8::internal::Heap::MaxHeapGrowingFactor+9620
 7: 00007FF69CBF07E6 v8::internal::ScavengeJob::operator=+24550
 8: 00007FF69CBEEE3C v8::internal::ScavengeJob::operator=+17980
 9: 00007FF69CBF7B87 v8::internal::Heap::MaxHeapGrowingFactor+2327
10: 00007FF69CBF7C06 v8::internal::Heap::MaxHeapGrowingFactor+2454
11: 00007FF69CD21EA7 v8::internal::Factory::NewFillerObject+55
12: 00007FF69CD9F096 v8::internal::operator<<+73494
13: 0000010597F5C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! play-with-technology@0.0.1 build: `npx webpack --config webpack.prod.js`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the play-with-technology@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxx\AppData\Roaming\npm-cache\_logs\2020-10-20T03_27_44_138Z-debug.log

Any thoughts? Googling says likely a memory leak, but since I am only compiling, wouldn’t that be a leak in VSCODE? Why only manifest when inspector? is inspector leaking?

Maybe you have to raise the memory allocated to your compiler.

When generating the packages for Babylon, I know we have to use a switch like --max-old-space-size=8192 so that the package can compile.

So to implement I would use this right?

set NODE_OPTIONS=–max_old_space_size=8192
npm run-script build

If so any other ideas as it did not work.
I did see this inspector error report here: How to use Inspector with ES6 Modules
But his case wont be fixed until 4.2, and I don’t know if this is the same error. Does not appear to be.

unfortunately webpack and ts are memory hungry during builds and as using the inspector usually imports the entire framework cause it can work with all of them, it creates a huge tree to parse for the tools creating to much pressure on the tools we use.

We had too even internally in Babylon bumped the memory limit quite substantially in our dev tools.

How does one go about bumping the limit in VS Code?

I tried --max-old-space-size=8192 in the build string
npm --max-old-space-size=8192 run-script build

I tried it in the package.json
“scripts”: {

    "start": "npx webpack-dev-server --config webpack.dev.js",

    "build": "npx webpack --max_old_space_size=8192 --config webpack.prod.js",

    "lint": "npx eslint . --ext .ts,.tsx"

  },

I downloaded a node module that said it would do it.
However, nothing seems to rid me of this error, and in looking at memory usage from task manager, nothing ever peaks above about 1.5Gb, so I must not be applying it correctly.

I have more than enough memory to do this.

I am sure this is one of those stupidly easy things, but after trying different old methods found searching I don’t seem to get it. Help?

First, as far as I know there is no way to allocate more than 8gb, which might be too little? I do wonder, however, what project requires more than that to compile successfully.

Will you be able to share your project’s code? With a way to reproduce the error? What node version are you using?

8 should be fine, I was having this issue since I downloaded the 4.1 and 4.2 NPM package, even with just a basic scene (lit sphere) - But ONLY with inspector called. It would make sense that if anything caused mem issues, inspector would, do to how it ties into everything else. Both in this post and others in the git its mentioned to pump up memory significantly to compile with inspector, but not really how to do that.

From what I can tell I only have the default 1.5G of mem usable. So it looks like my efforts to change that higher have failed. Which usually means I did not correctly apply the preference change with one of the commands listed above.

At least I think that is what this is telling me:

[23284:000002809986AF80]    63624 ms: Scavenge 1367.5 (1423.7) -> 1366.8 (1424.2) MB, 2.6 / 0.0 ms  (average mu = 0.223, current mu = 0.195) allocation failure
[23284:000002809986AF80]    63628 ms: Scavenge 1367.7 (1424.2) -> 1367.0 (1424.7) MB, 2.6 / 0.0 ms  (average mu = 0.223, current mu = 0.195) allocation failure
[23284:000002809986AF80]    63632 ms: Scavenge 1367.9 (1424.7) -> 1367.2 (1425.2) MB, 2.3 / 0.0 ms  (average mu = 0.223, current mu = 0.195) allocation failure

Unfortunately, as I would love a good audit to improve my style, my projects grown beyond what can be put in playground, too many classes to paste in. Everything does work fine without inspector, but as soon as you call inspector. Fatal error.

So I think I just need the correct command to set max a bit higher in VS Code (or node for windows), I just went strait for eight figuring that would for sure fix it, if that was the cause, but would not kill my system.

These are my packages being used:

    "@babylonjs/core": "^4.2.0-beta.9",
    "@babylonjs/gui": "^4.1.0",
    "@babylonjs/inspector": "^4.1.0",
    "@babylonjs/loaders": "^4.2.0-beta.9",
    "@babylonjs/materials": "^4.1.0",
    "@babylonjs/post-processes": "^4.1.0",
    "@babylonjs/procedural-textures": "^4.1.0",
    "@babylonjs/serializers": "^4.1.0",

you should not mix versions