Reputation: 7255
Information:
I have a database table with 200.000 entries.I am using an ArrayList
which holds 100 Buttons
each time(Each Button
has the info from the table entry it matches).
When the right arrow key is pressed the ArrayList
is being cleared and the next 100 entries of dataBase table are added(as Buttons
).
What i want to say is that every time i search the dataBase or i press left or right keys the ArrayList
is cleared and added with 100 new Button
.
The Problem
Should i reuse the existing buttons passing different values or just clearing them and creating new ones?
If i create new Buttons it consumes more memory ?If i reuse the same Buttons it doesn't consume extra memory?
Upvotes: 0
Views: 334
Reputation: 1787
It's hard to give a clearly response. You can test your own application for both cases.
First one view difference of memory, like this:
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
And test how fast your application will work, in header declare new variable:
Date start = new Date();
In end of app
new Date() - start;
And you will answer yourself.
Upvotes: 1