-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PW4: Memory above 93 leads to device freeze on exit - a potential memory leak? #7853
Comments
Is that a PDF?. In that case memory should grow until a certain threeshold, then stop there. On my device it reaches 300MB usage, but everything works normal. On the other hand, crengine memory usage depends a lot on the current document. But it never pass 100/150MB on my own usage.
Probably not -at least on crengine- I read on my Bq almost every day and don't update often, so it can be running the same luaJIT instance for months.
Probably. Kindle devices run a bunch of stuff under the hood. |
Kindles are apparently extremely memory constrained. |
I was going to ask on which FW version this is, but, given that it's a PW4, it's going to be recent enough, so, yeah: extremely memory constrained. |
The difference in behavior on exit purely stems from what the OOM killer targets first. Given that the worst offender is the native system, it indeed makes perfect sense that it gets killed first, which yields confusing soft-locks on exit. |
You could possibly cobble something up by stopping/restarting the KF8 & KFX readers and a few other non-essential auxiliary daemons, but unfortunately, the worst offender is the JVM, and that's a tougher nut to get rid of without hampering functionality. |
I don't have an affected device, but if someone's willing to do the work, I can point you in the right direction. |
@NiLuJe, please give me directions I'll investigate it further. |
The other strange thing that I found the memory is freed only after Koreader restart and not after a book close - maybe it's a good ocassion to free memory/cache ? |
Basically, check the process list, and look for stuff that isn't critical (e.g., cvm, pillow, blanket), and look for the matching upstart job, and look at that job's dep graph to see if it can be easily stopped/started without wreaking havoc. I mentioned the KF8 & KFX readers because they're somewhat obvious, and I have experience with doing just that to the KF8 reader in the font hack.
Any Kobo (except the upcoming one which we can't support without basically a new port, because sunxi). |
Anything that can be released on book close already is. |
I tried this on PW3, with
Killing
How to check this?
As well as this? |
@NiLuJe, my initial finding are as follows: M130 (a PDF file)
M90 (a PDF file)
after restart
So basically the biggest memory increase is by Please give more details on dep graph monitoring if needed. |
maybe you guys can make something like this #7823 , its a solid solution if you ask me... hashtag just sayin ;) |
I dug a little further... (!) I have USBNetwork over Wi-Fi auto-starting on boot, as well as Rescue Pack and Coward's Rescue Pack, so make sure you have too before trying this. (!) In the
So, naturally, I went ahead and created this file. Then did Half-success I guess? |
P.S. Obviously, I wouldn't try to restart Kindle with that file existing :D |
Yea, I've seen that - for me it's more like a workaround than a problem solving (that is what causes memory increase). Still better than constant crashes though. |
We can't kill the framework, because we lose suspend/buttons/wifi and a whole bunch of other things I might be forgetting, which is precisely why the "no framework" button is disabled on FW 5.x ;). Of course, reinventing the wheel and making no framework behave on FW 5.x is another possibility. It's a much harder task requiring a lot of low-level potential device-specific stuff, though; and I'd probably veto it because it'd be a maintenance nightmare ^^. |
As for the ps output: of course cvm isn't budging: we're SIGSTOP'ing it. The issue is the insane memory pressure 'it' (and all its friends) puts the system under just by being, not what it does while we run. |
Much like |
After some parameters tweaking I've discovered that the best Maybe it's a good idea to use different default values based on a device model? |
Err, 0.6 is higher than 0.4. You could distinguish between Kindle (something like 0.2-0.4) and all the rest (more like 0.6-0.8) but there's no need for it really. |
Right, seems counter-intuitive but works so far - I still need to investigate it further though. |
You need a certain amount of memory to render something like a high res PDF. That's not so much an issue as just a thing that is unavoidable (of course you can preprocess them to be more embedded device friendly, pdf2djvu perhaps being the quickest and easiest method). That's why it's at a value like 0.4 and not at 0.8. It'd probably be possible to more or less detect that and refuse in advance but I think that's about it. If there were an actual issue it'd be crashing constantly on Kobo too, which it doesn't. But it does need a little breathing room — quite little really. PS You can also try disabling all plugins you don't use. The impact should normally be negligible but even just a few MB might make a difference in these extreme conditions. |
In /etc/upstart/framework there are these lines:
I tried to comment out the first section to make it think this is a 256 MB RAM device, so framework would take less RAM. However, it didn't help. The same 7-10 MB free in KOReader. Does anybody know what it is supposed to do? |
By the way, does KOReader work with swap file if such was created? Like explained here. |
A swap file on eMMc is a terrible, terrible idea. |
@NiLuJe |
To be fair, a swap file anywhere is mostly always a terrible idea ;o). Sane modern systems in this situation should vastly prefer zram/zswap. Unfortunately, these do not qualify as "modern" systems ;). |
Since we are talking about the memory. Will it be more informative to show "Free memory" instead? We can get it from Line 106 in e4a333a
If so, the warning in #7857 might be set up depending on the "Free memory" as well. |
I'm much more interested in KOReader's actual memory consumption than the available memory as a user, FWIW (as it's a non-issue on sane devices ;p). Code & user have different goals there. |
Returnng to your #7857 (comment), how can we set a threshold based on a parameter which we cannot watch anywhere? |
We covered that already: #7857 (comment) (i.e.,: we don't ;p, you can forget that earlier comment ;)). |
@NiLuJe |
@NiLuJe
Is this related to new |
P.S. All the installed fonts showed up fine, and there are no warnings during startup in the crashlog |
The new |
@mergen3107: Unrelated. Possibly mildly fronts related, though? (maybe #7806) |
@NiLuJe |
As for 7806, no, I don’t think it looks the same in my case. My crashes happened only after I hit restart. Also, I wasn’t testing fonts in KOReader yet, because I just uploaded them via WinSCP and wanted to restart KOReader first, to make these fonts appear. |
I'll chalk it up to Kindle fsp gremlins then ;). (In any case, can't really tell much about a segfault without a gdb backtrace from a debug build). |
What debug build should I get? Is there a newer version since you mentioned in 7806? |
That one's for Kobo, so, nowhere ^^. If you can actually somewhat reliably reproduce it, I can build you one, though. |
OK! I’ll try to dump all the new fonts I uploaded yesterday back to Kindle to see if I can catch it again |
Adding to that, when KOReader crashed in #7869, all my collections in Kindle Menu were gone. I think it might be related to the fact that KOReader didn't have a chance to relaunch these processes it killed at the startup. I am not sure though. I just rebuilt collections in LibrarianSync and they showed up again. |
Both sound unrelated, and just possibly the OOM killer having killed some stuff in the meantime... (We certainly don't kill anything related to networking or device monitoring, for obvious reasons ;)). I'll double-check, but, IIRC, that behaved just fine on my end. |
Yup, works just fine on my end (PW2, 5.9.7, for reference). I tweaked the ordering in #7868 to make the fact that we're finished clearer, but it shouldn't change a thing in practice. |
On my side those were just icons refreshing problem that didn't happen before. My guess was that after crash it didn't call restart as expected. However it still may be unrelated as you said. |
Issue
The longer I read the higher memory consumption goes - memory leak?
The only solution that I'm aware of is to restart a KOReader, then exit.
I tried adjusting
DGLOBAL_CACHE_FREE_PROPORTION
but without success.Steps to reproduce
After 93 when I try to exit my kindle freezes (OOM?).
Above 150 while reading it freezes a device (OOM?).
The text was updated successfully, but these errors were encountered: