Fork me on GitHub
#beginners
<
2021-08-29
>
Kenneth Gitere11:08:12

Hi all, I'd like to try my hand at some Cljs so that I can get a feel of making UIs in a data driven approach which will hopefully help me carry those concepts to other langs like JS/TS where data driven approaches aren't mainstream yet. Does anyone have any good recommendations?

lepistane15:08:31

Hello, i've made this app that eats up memory after few days of running and i am not sure how to go about fixing it. I've heard about memory leaks but never had the pleasure to debug them. Could this be it? How do i analyze memory usage over time? I've got some basic monitoring done and i see that heap oscillates between 300-600mb but ram usage climbs till 77% and then randomly spikes to 80-90% and then i have to restart the app which brings memory usage back to 40% and then it climbs. Does anyone have any pointers about what should i do or how to approach this? I've used https://www.reddit.com/r/Clojure/comments/g68uvy/creating_a_jvm_heap_dump_from_the_repl/ and memory analyzer to look at heap dump but i don't see any useful information there... clojure.lang.var = 15% of bytes used this could be anything because i am using mount to keep some state on the backend. Is looking at heap wrong thing to do ?

schmee17:08:52

the heap is the right place to look!

👍 2
ghadi19:08:38

@U45SLGVHV do any of your components' states have caches, atoms, or similar object retention?

raspasov23:08:02

@U45SLGVHV A few things: 1. How much total heap are you running? From my experience, ~2GB is the minimum when I was running a Clojure JVM container on AWS ECS. Otherwise, the container might get killed. 2. When you say “randomly spikes 
 and I have to restart the app” what do you mean precisely? Is the JVM “frozen” or it “exits”? 3. On a scale of 1-10, how positive are you that you have a memory leak? As per point 1., you might simply need more heap. The JVM GCs can act in unexpected ways and generally require a good chunk of memory with Clojure, in my experience.

raspasov23:08:31

I am making the guesses above because you mentioned “300-600mb” which is pretty tiny, as far as JVM Clojure is concerned.

lepistane08:08:34

@U050ECB92 yeah there are about 5 atoms that hold state of different parts of the app. That state is used in different parts of the app. As i mentioned i am using mount state management lib @U050KSS8M 1. Total memory is at 2gigs at the moment. Usually used is about 1.5gigs but heap max is 800mb and usage is what i shared above. 2. The app starts to become slow and sluggish visually (by using the UI) looks like something is wrong, it takes long time to ssh into the instance. After restart everything is good 3. well i am not sure, i've noticed that memory usage steadily climbs and i am afraid GC isn't clearing something that it should be. So i just want to make sure that it isn't a leak

lepistane14:08:46

I decided to allocate more heap and bump up the instance, It seems that memory peaks and lingers around some % of memory used. This will definitely show if memory leak is preset, because if it is i expect memory to rise more and more. One question is there a way to find out which clojure namespace/function that's related specifically for the code base uses most memory or possibly has memory leak? I've used VirtualVM but most memory consuming objects where bytes[] and java.lang.Object[] i didn't find anything about the problem with this 😞

raspasov18:08:32

@U45SLGVHV I don’t think there’s a straightforward way to locate a memory leak as related to a function/namespace.

raspasov18:08:56

See if you are still having an issue after bumping up the RAM.

lepistane10:08:18

that's a shame. I am seeing steady climb in last 24h but it's so gradual like it came up 10% from 28% to 38% memory used. heap used seems to be grabage collected so i am seeing up and down a lot but this upward trend could be problematic 😞 i expect it to peak at 40% and stay there cause that would signify same amount of memory used just different instance

José16:09:59

hello, just curious about the outcome. Did the instance type upgrade solve it?

lepistane09:09:45

Hi, yes and no we don't have errors anymore (obvious because there is more ram) but there is still memory leak somewhere that causes memory usage to go up 3% over last 3days. This is something i can live with because of i every 2 weeks or so. I have suspects what could cause that gradual growth but it's not worth investigating at the moment

👍 2