X Tutup
The Wayback Machine - https://web.archive.org/web/20201121182630/https://github.com/metosin/compojure-api/issues/366
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0.0-alpha* version out of memory #366

Open
chenjianye opened this issue Jan 12, 2018 · 8 comments
Open

2.0.0-alpha* version out of memory #366

chenjianye opened this issue Jan 12, 2018 · 8 comments
Labels
bug

Comments

@chenjianye
Copy link

@chenjianye chenjianye commented Jan 12, 2018

Library Version(s)

2.0.0-alpha2 ~ 2.0.0-alpha17

Problem

The server use Clojure 1.9 and spec, set JVM -Xmx=384m. Post data to server repeatedly, and then server terminate by "OutOfMemoryError" later.

And version 1.1.11 and 2.0.0-alpha1 have not this error.

@chenjianye chenjianye changed the title 2.0.0 version out of memory 2.0.0-alpha* version out of memory Jan 12, 2018
@ikitommi
Copy link
Member

@ikitommi ikitommi commented Jan 19, 2018

Hi. Could you provide a minimalistic app that fails? Thanks.

@ikitommi
Copy link
Member

@ikitommi ikitommi commented Feb 13, 2018

haven't seen this, could you provide some failing sample?

@chenjianye
Copy link
Author

@chenjianye chenjianye commented Feb 24, 2018

I am so sorry that I was on vacation and didn't see the mail in time.
The example is here:https://github.com/chenjianye/Compojure-api-error-example

@asheldo
Copy link

@asheldo asheldo commented Mar 3, 2018

The heap dump shows hundreds of thousands of spec_tools.Spec's -- but this is on 0.5.1 of spec-tools. It won't run under 0.6.1.

@ikitommi
Copy link
Member

@ikitommi ikitommi commented Mar 5, 2018

Thanks. The spec-memoization is clearly not working. On vacation now, can fix that easily when back on computer. To shield against regression, do you know a way to create a unit/system test that would tell if the number of Specs grows in use? I don't.

@asheldo
Copy link

@asheldo asheldo commented Mar 5, 2018

Interesting. Just getting back into clj thinking, so maybe -- junit mock fmwk's would in Java space assert on "times(1)" the method calls.

@ikitommi
Copy link
Member

@ikitommi ikitommi commented Mar 13, 2018

back.

memoization fails as the (s/coll-of map?) returns different instance each time and misses the cache. Still, the cache should have been a fifo of 10000 entries, so it shouldn't cause OutOfMemoryError. I dropped the cache max size to 1000 anyway as starters, but not a real fix, in alpha-19.

I think a real fix would be to replace the Coercion implementation to the one from reitit - which is a polished version of the c-api original. With it, the coercers are created once per endpoint, and no memoization is needed. Currently, in c-api, it's resolved at request-time, memoization to keep it fast.

Could you test that the number of Specs floating doesn't go much over 1000 to verify that the fifo works as expected?

@ikitommi ikitommi added the bug label Mar 13, 2018
@asheldo
Copy link

@asheldo asheldo commented Mar 14, 2018

Will do, and let you know -- thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.
X Tutup