no your not using it wrong
On Mon, Nov 15, 2010 at 4:37 PM, kk kkostia...@gmail.com wrote:
Just to make sure, can someone please tell me if I'm misusing
StringBuilder here.
This is what I do:
private StringBuilder m_healthString = new StringBuilder(8);
I update by doing:
George,
Is it meant to alloc every time you call it then?
That's going to cause GC to collect at random times during my game :(
cheers,
kk
On Nov 15, 4:40 pm, george barber finchbar...@gmail.com wrote:
no your not using it wrong
On Mon, Nov 15, 2010 at 4:37 PM, kk kkostia...@gmail.com
I am maybe talking out of my a**, but I have a feeling that you may
never be able to get rid of that allocation. Using Drawables to draw
your game graphics indicates to me that yours is more of a casual game
where top performance and occassional GC pauses are not that big of a
deal. Or Google
Hi all,
Got rid of all the Integer.toString allocations by having my own
intToString method and using char[] as suggested.
The only thing showing now on the DDMS allocs are the
Drawable.setBounds calls (lots of them).
I've used both the rect version and the four-ints version of setBounds
but they
DanH,
I've had a look at the allocations using DDMS. The only things that
are being allocated during the game (that I have control over) are
Integer.toString and Drawable.setBounds calls.
Also, I calling System.gc() periodically and it logs the time taken
to do the collection...It doesn't seem
SetBounds has a version that takes four integers - no new Rect is
necessary.
As for Integer.toString - it's easy enough to write your own version
that outputs the result into a supplied char[] buffer, that's only
allocated once. Canvas.drawText() has a version that takes char[].
But I
Just to make sure, can someone please tell me if I'm misusing
StringBuilder here.
This is what I do:
private StringBuilder m_healthString = new StringBuilder(8);
I update by doing:
m_healthString.replace(0, 8, Integer.toString(myHealth));
Is this expensive/wrong? Is there a better way to update
On Mon, Nov 15, 2010 at 8:37 AM, kk kkostia...@gmail.com wrote:
private StringBuilder m_healthString = new StringBuilder(8);
I update by doing:
m_healthString.replace(0, 8, Integer.toString(myHealth));
Is this expensive/wrong? Is there a better way to update a
StringBuilder with a new
What I was suggesting was, rather than using Integer.toString(), or any
other String / StringBulider methods, format the value yourself.
In class declaration:
char[] mMyHealthStr = new char[8];
int mMyHealthLen = 0;
When drawing:
// convert integer to string in mMyHealthStr, set mMyHealthLen
Top stuff Kostya/Dianne. Thank you for the feedback.
I think before I look into anything else, I should do this first to
get
rid of the thousands of micro-allocations that take place there.
UI elements are drawn about 20 times per second and although I cache
values that don't change, a lot of the
How many different integer values do you need? You could generate a
few hundred strings in advance and use a look-up table for speed.
Also, are you using SQLite or the Preferences editor? Those can slow
down as the amount of data they use gets larger.
On Nov 14, 10:54 am, kk kkostia...@gmail.com
Hey all,
Thank you for your replies. I don't use SQLite or the Preference
editor.
The string lookup is definitely something worth considering.
In terms of profiling, I do:
Debug.startMethodTracing(g1);
in OnCreate and then stop tracing in OnDestroy.
Are you saying that I should create 2 trace
Yes use the am profiling command (adb shell am profile ...) to start and
stop profiling early on, and then later when it is slow, and see what is
different.
On Sun, Nov 14, 2010 at 2:35 PM, kk kkostia...@gmail.com wrote:
Hey all,
Thank you for your replies. I don't use SQLite or the
My guess is that you have a slow memory leak, and GC is taking more
and more time (and happening more frequently) as the garbage builds
up. You need some traces and profiling to figure out what's going on.
On Nov 14, 12:54 pm, kk kkostia...@gmail.com wrote:
Hi all,
I've written a game and
14 matches
Mail list logo