question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Massive memory consuming when require('opentype.js') is run

See original GitHub issue

Massive memory consuming when require(‘opentype.js’) is run in html of electron app I’m trying to use this library, but when I add

const opentype = require('opentype.js');

to my code. and It runs. but when I try to open DevTools it consumes all of my memory 5.6GB and it crashes.

I’m on a Electron project. I tried the code in the Main process and the renderer process and within the html code. All the same problem happens.

  • I don’t have problems using other packages by require()
  • I uninstalled opentype.js by npm and reinstalled several times. to see if I destroyed it somehow.
  • If I try calling opentype.js in plain html, it works fine.
  • try calling in express app process, it works fine also.
  • I think it maybe an electron issue. Anyone who successfully used it in electron?

Environment

Version used: 0.8.0 Font used: none Node version: v8.10.0 Operating System and version (desktop or mobile): Windows 8.1/10, and OSX

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
minsikimcommented, Mar 16, 2018

Solved it by detuoring opentype variable through main process and passing it with remote module in electron

//in electron main process
global.opentype = require('opentype.js');
let mainWindow = new BrowserWindow();
mainWindow.webContents.send('init-opentype', opentype);
//in renderer process
var opentype = remote.getGlobal('opentype');
console.log(opentype);
>>Object {…}, BoundingBox:(...), Font:(...), Glyph:(...), Path:(...), load:(...).....

but still not sure why it doesn’t work directly in the renderer process I’ll notify when it all clears up.

@Jolg42 thanks again for advice

1reaction
Jolg42commented, Mar 14, 2018

I won’t have the time to investigate this issue unfortunately but you should add a link to you repository if it’s public as an example.

I guess the best way to know what’s happening will be to record the memory consumption and see where it’s being allocated.

You could try: https://electronjs.org/docs/tutorial/debugging-main-process https://github.com/sindresorhus/electron-debug

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't load `hmtx` table until it's actually needed · Issue #135 ...
The hmtx table loads all glyph advanceWidth and leftSideBearing values, which is fine for small fonts but for large fonts this puts a...
Read more >
Is it normal for Webpack to take over 9GB of memory?
It looks like your process takes 1GB, but since they are executed 8 times, as separate processes... then they take 8GB of ram....
Read more >
nodejs with nginx proxy , memory usage - Server Fault
js may use 85-90% of all available memory but it runs super fast and there is nothing wrong. The high memory usage may...
Read more >
opentype.js - npm
OpenType font parser. Latest version: 1.3.4, last published: a year ago. Start using opentype.js in your project by running `npm i opentype.js`.
Read more >
Node.js Memory Leak Detection: How to Debug & Avoid Them
js uses Chrome's V8 engine to run JavaScript. Within V8, memory is categorized into Stack and Heap memory. Stack: Stores static data, method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found