Giter Club home page Giter Club logo

Comments (10)

kirillDanshin avatar kirillDanshin commented on August 15, 2024

@iKonrad pprof files gives 404 error

from goja.

iKonrad avatar iKonrad commented on August 15, 2024

@kirillDanshin oops, my bad. here are the correct links:

http://jarosinski.uk/files/heap_base.svg
http://jarosinski.uk/files/heap_current.svg

from goja.

dop251 avatar dop251 commented on August 15, 2024

Most likely it's a leak in JS code. However, there is a possibility that goja may be responsible as well, the value stack is only cleared after RunProgram(). I'm going to add a bit more aggressive cleaning which could make a difference in you case, give it a try. If it doesn't I'd like to see JS code.

from goja.

iKonrad avatar iKonrad commented on August 15, 2024

Thanks for your reply!
Unfortunately your change didn't help much. Still the heap gets high and is not released.

JS is a react.js application.

I can't paste the entire react application, but here's the "toString.js" file that handles exporting the React.js to string and sending it back to goja:

https://gist.github.com/iKonrad/5a9ab16be0f253f3d9f1ee2683d77082

Also, the following is go code that creates the goja instance:
https://gist.github.com/iKonrad/6f3528e35e2d5b522fbed6c99d336ec7

newJSVM function creates a new eventloop. Handle gets called for every request

Also, in the toString.js file, global[cbk] has the __goServerCallback__ function passed from the VM.

If you need any other code, feel free to let me know.
Otherwise, do you have any suggestions on how to trace JS memory leaks on server-side?

from goja.

dop251 avatar dop251 commented on August 15, 2024

Same methods as for generic memory leaks in Go apply, there is nothing specific in goja I'm afraid. I would probably try writing memory dump.

from goja.

iKonrad avatar iKonrad commented on August 15, 2024

Alright. It must be the React application that's leaking the memory.
In that case, there's no point in keeping this thread open.
Thanks a lot and keep up the good work.

from goja.

dop251 avatar dop251 commented on August 15, 2024

No problem. Feel free to reopen if you find out it's actually goja.

from goja.

olebedev avatar olebedev commented on August 15, 2024

@iKonrad, are there were your app specific leaks or React in general? Just wondering if it's a go-starter-kit's specific stuff or not.

from goja.

iKonrad avatar iKonrad commented on August 15, 2024

@olebedev

I did load testing to the bare go-react-kit project as well, but it was working fine, so i thought it must be something else.

I spent a good few hours yesterday and it turned out that, as @dop251 suggested, it was a memory leak in JS.

See, in the toString.js gist I've posted above, for some reason I've added memoryHistory thingy from react-router. Then I'm adding the syncHistoryWithProps to the renderProps array which caused a massive memory leak. I can't remember what I was trying to solve with it, but I think memoryHistory is pretty useless when there's match, isn't it?

Either way, the leak's fixed! :)

from goja.

olebedev avatar olebedev commented on August 15, 2024

@iKonrad, oh, sure. It doesn't make sense to use in-memory routing and ssr.

from goja.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.