![]() |
#1 | |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 44444
Join Date: Aug 2013
Device: Kindle Paperwhite (5.3.4 JB)
|
Questions on memory leaks and exit practices.
According to cowlark,
Quote:
If it is a problem, can someone explain it a little further? Is it just static members I'm setting in the classes I use, or are includes also wasting memory until the kindle is reset? Again, if so, would two apps include-ing the same class cause twice the amount of memory wasted, or is it limited to one per Java class name? Even supposing that isn't true at all, how do you all shut down your apps? Not necessarily what technique you use to avoid the home button, but how do you clean up? What can I trust the garbage collector with? |
|
![]() |
![]() |
![]() |
#2 |
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quite simply: the statement is completely wrong.
A static member is just a member that is not associated with an instance of a class, but with the class itself (rather: with its class object). And unlike "normal" objects (class instances), class objects will not be garbage-collected as long as the class is loaded, because they don't go out of scope or become orphaned. So far, so correct. However -- and this is the important point -- every Kindlet is instantiated in its own, isolated, classloader. All of the classes and instances of that Kindlet only ever live inside that classloader. And when the Kindlet is terminated - poof! - the class loader and everything that was "produced" by it is discarded and can be garbage-collected. Unless there are memory leaks inside the JVM implementation, this is no problem at all, and the statement simply shows a lack of understanding of how the class loading mechanism works and is implemented on the Kindle. (more technically, we're talking about ClassLoader delegation and isolation... ask your favorite search engine about it). Admittedly, this is not the easiest topic to wrap your head around, but the Kindle uses the same technique as any other "application server"/"web container"/whatever you want to call it. If it didn't work, half of the WWW would constantly be crashing because of OOM errors ![]() That said, yes: the Kindle does have rather severely limited memory, and if you aren't careful, it's relatively easy to hit the roof. But the problem that you're referring to just isn't a problem. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 44444
Join Date: Aug 2013
Device: Kindle Paperwhite (5.3.4 JB)
|
Awesome, thank you very much for the reply!
I hope to be active in this community for a while, very tempted to write an IRC client at the least. |
![]() |
![]() |
![]() |
#4 | |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Quote:
You might want to check it out before starting your own version. Not that we have any objection to having more than one flavor of anything posted, just that it might save you some time. |
|
![]() |
![]() |
![]() |
#5 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
So err, keeping in mind that I'm terrible at Java, and when Hotroot mentioned this on IRC it reminded me of it:
What does those mean in the logs, when closing a Kindlet (KUAL, in this case): Code:
130805:223901 cvm[1738]: I GarbageMonitor:GarbageMonitorInfo:status=eligible,description=KindletClassLoader for appId= test,object=1081632425:Can now be collected 130805:223901 cvm[1738]: I GarbageMonitor:GarbageMonitorInfo:status=collected,description=KindletThreadGroup for appId= test,object=43152587:Collected 130805:223901 cvm[1738]: I GarbageMonitor:GarbageMonitorInfo:status=collected,description=KindletClassLoader for appId= test,object=1081632425:Collected 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::AppContext.dispose() failed to shut down ThreadGroup correctly; waited some time and now about to invoke ThreadGroup.destroy() directly. Details of active threads are: 130805:223901 cvm[1738]: I GarbageMonitor:GarbageMonitorInfo:status=watch,description=Cleanup Thread for static variables in Kindlet,object=-1528622242:Watching 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: W StandardKindletContainer:GenericWarning::Error occured while cleaning up Kindlet application classes 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Unable to clear static field 130805:223901 cvm[1738]: D StandardKindletContainer:GenericDebug::Cleanup of statics took: 19 milliseconds 130805:223901 cvm[1738]: D BookletSandboxKindletProcess:GenericDebug::After shutting down sandbox, un-cleaned windows remaining = 0 130805:223901 cvm[1738]: D BookletSandboxKindletProcess:GenericDebug::kindlet process destroyed 130805:223901 cvm[1738]: D AbstractBooklet:Entering stop:booklet=com.lab126.booklet.kindlet: 130805:223901 cvm[1738]: D AbstractBooklet:DebugInfo::Removing all chrome header button listeners for booklet com.lab126.booklet.kindlet 130805:223901 cvm[1738]: I KindletBooklet:stop:timeTaken=2058,freeMemory=9517180,lifecycleEventType=switch-out,units=ms:stop |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
@NiLuJe: in simple terms, yes.
What I wrote above was slightly simplified, because Kindlets of course don't only use classes from their own classloader (but from parent loaders too - like JButton), and they are able to spawn new threads (but only inside their own thread group, so these can again be killed as you see above). I don't know what the "unable to clear static field" is trying to say exactly - it might be related to not being able to re-assign static final members (setting a field to null is a common measure to help the garbage collector, but it won't work on final fields for obvious reasons), or it might be something else. But yeah, for all practical purposes, just assume that you don't have to worry about cleaning up after yourself. That's one of the beauties of the JVM. I'm starting and restarting Collections Manager dozens, if not hundreds of times during some dev sessions, and I'm never really experiencing issues that could be related to memory management (well, except if I'm doing stupid things myself ![]() |
![]() |
![]() |
![]() |
#7 |
BLAM!
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 13,506
Karma: 26047190
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
|
@ixtab: Great, thanks for clearing that up
![]() |
![]() |
![]() |
![]() |
#8 | ||
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
![]() Just a few hints: 1. If you're just getting started with Kindlet development, it may help to take a look at the existing Kindlets' source code. 2. If you want to do non-trivial things, like reading/writing files, accessing the network etc. you're likely to need the Kindlet jailbreak sooner or later. You can find examples of its use in the KUAL or Collections Manager Kindlets. 3. Please use the existing "test" certificate instead of creating your own to sign the .azw2 files. See the KUAL sources for an ant script. This way, your Kindlet will work out of the box for users who have the "mobileread dev certs" package installed. Quote:
![]() (*) as long as you don't try to mess with the Kindle internals too much, that is. But that is only due to the close-minded "we do closed source, hands off our device" developers over at lab126. Yeah, I just had to say that again ![]() Last edited by ixtab; 08-05-2013 at 05:30 PM. |
||
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7
Karma: 44444
Join Date: Aug 2013
Device: Kindle Paperwhite (5.3.4 JB)
|
@ixtab
1. I've been looking at a few, but I'll download a few more to get a better overview. 2. I still don't understand the kindlet jailbreaks. I only ever see links to its download page, never a forum page explaining it. 3. Yep, been doing that. @knc and ix I assume you're referring to the irssi port? I really didn't like what I saw. I agree that stuff tends to look better when its developed natively, and I'm pretty good with UI stuff. |
![]() |
![]() |
![]() |
#10 |
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
|
1) Good call. Check the wiki and do a search on here. (There are various lists)
2) It patches a tiny bit of code in one file. (or replaces it with a good one, I forget) IIRC. Essentially altering the security scope of kindlets. (extra /mnt/us) 3) Nice one. one less headache. Further to what Ixtab said, yes kindlets are sorely underused, anyone getting excited about them is a great thing. |
![]() |
![]() |
![]() |
#11 |
THE NOOB
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 701
Karma: 1545649
Join Date: Jan 2012
Location: Italy
Device: Kindle Touch 5.3.2
|
Sorry to hijack (also) this thread, but I don't feel like opening a new one for such a small question...
Does anybody here know how does the Garbage Collector work for WAFs? Is it the same used for the browser or do I need to load it in some way? I'm a bit concerned on performance and I would like to be reassured on this! As always, thanks gurus!! |
![]() |
![]() |
![]() |
#12 | |
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
![]() And here, deeply hidden in the forum dungeons, is the background information (read the entire thread). HTH ![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Questions about CSS and best practices | graycyn | ePub | 8 | 03-18-2012 04:15 PM |
Questions about best practices: InDesign CS5 to ePub (file formatted for printing) | mtrahan | ePub | 15 | 06-17-2011 03:43 AM |
AAGGGGGGGGGHHHHHHHHH - Memory Errors, Leaks and WTF's! | mightymouse2045 | Calibre | 2 | 05-26-2011 12:22 PM |
Inline SVG questions (whitespace & other practices) | politicorific | Workshop | 6 | 04-12-2009 05:32 PM |
Memory Stick Questions | MickeyC | Sony Reader | 6 | 01-18-2008 08:43 PM |