Closed samehissam closed 8 years ago
thumbnails performance report
Overall notes and opinions:
Manually remove invisible rendered pages:
commit # 759df774f0d8e35571cb9c03caa8bb401077047b.
The previewed pages were set to null
when it's not visible. The memory at the beginning of is about 50 Mb and increases by viewing more pages, It turned out that null are reference if the variable is assigned according
to this question.
Writing a cutom ListModel::
commit # 773bded7a27580cc67277d56e2440f3087cf9efd.
Wrote a custom list model to store data in with only one page to guarantee no more pages are buffered or unintentionally stored in memory, By extending AbstractListModel
. Got the same previous result.
11ce7c0abc94add13fa5b4c3760bbbe336a8d6d1
CachedInputStream
which contained a Datapool
object, In other word all the pages that were rendered were cached. This maybe for CPU resources saving, Note that this software was written in late 90s so this was a big deal.cached
in Document
class, So that we don't lose the original caching computed pages - Just in case we needed it again -.By default the min and max heap sizes is are 40%, 70% in order, Although you can change this but it's done by changing the JVM parameters in every machine that runs the application.
So a couple of spare mega bytes doesn't worth the effort or the time, And also using this solution may actually slow down other operations that uses a lot of memory suddenly.
-Xms
parameter in this Oracle Doccommit : 31c48fe5580abdc3c057b51380fc1c0e0bf6cd68
AbstractListModel
called "PagesModel" and renders each page upon the JList
's call.Solution:
Add a AdjustmentChagedListener
to the JList
's ScrollPane
and start a thread to render pages when the user scrolls the page. Unfortunately I forgot to commit this solution and tried the next one.
Result: The Lag was gone but the memory suffered significantly form this approach in case of flipping pages at a fast pace.
Explanation: There is a thread created/started by flipping each page, Although the thread is interrupted It's Variables are kept in the memory until the JVM's garbage collector removes them even if there are removed form the used memory the heap is still affected by the significant memory change.
1- Comment code using java doc. 2- What is the main problems that take much time in execution. 3- Try to solve this problems with available code. 4- If no change in performance change the available code with other that achieve your goal.