Android : How to Store Drawing Information Efficiently

on Sunday, August 31, 2014


I have a bunch of crude graphic objects and I want to draw them efficiently (meaning with a good ratio of fast and without much memory overhead). Think of something like "draw 4 circle next to each other" and even with a bit more logic like "draw as much circles as fit in this space". The kicker is: There are hundreds of different drawing instructions, but only a dozens or so are effectively used at once.


As a programmer, that screams for an interface, where the implementations do the actual drawing, but that also means having hundreds of classes, which after their first use will not get garbage collected. Also there might be a lot of duplicated code and big maps of some kind that hold strings and classes to be initialized.


Another option might be XML files, which Android can handle well. Maybe even SVG files, but for the logic I need I will probably need my own format as well. These files might need a bit of time and memory to get loaded, but unused components can be garbage collected well. This approach would also need some kind of registry to register all these files, and skipping through them would be very slow (but this is hardly ever needed, if at all).


I don't think that is an unusual request (having a lot of potential information where only a small percentage is used at a time), so I want to know: Is there another way I'm missing? What is the correct way to approach this problem? What are the professionals doing?


0 comments:

Post a Comment