Android :: Avoid Garbage Collection Delays In Java Games?

Mar 20, 2010

I'm performance tuning interactive games in Java for the Android platform. Once in a while there is a hiccup in drawing and interaction for garbage collection. Usually it's less than one tenth of a second, but sometimes it can be as large as 200ms on very slow devices. I am using the ddms profiler (part of the Android SDK) to search out where my memory allocations come from and excise them from my inner drawing and logic loops. The worst offender had been short loops done like,

for(GameObject gob : interactiveObjects)
gob.onDraw(canvas);........................

Android :: avoid garbage collection delays in Java games?


Android :: Droid Camera Garbage Collection / Way To Avoid It

May 25, 2009

I am developing a camera application , where the frame rate is important. However, camera uses a preview callback function which allocates a byte[] array of 230400 bytes, which makes it necessary for the garbage collection to step in. Can someone suggest me a way to avoid garbage collection stepping in?

View 10 Replies View Related

Android : Latency Due To Garbage Collection On On PrevFrame

Jun 6, 2010

I'm writing an Augmented Reality codes that should works in realtime,

But the VM's garbage collection hinders my program's performance.

I checked my program's execution time for each in OnPrevFrame(byte[], Camera)

and it execution time increases from around 50ms to 120ms at just after each garbage collection.

I copied parts of logs below. (local time is just before and after of signal processing, and global time is time stamps for every onPreviewFrame() calling )Also I executed onPreviewFrame without any signal processing on it, but

the garbage collection is also carried showing debugging message around 60ms it spends for memory release.

Is this garbage collection come from releasing byte[] yuvs image data? ( i uses 320x240 thumb nail )

then this clearly comes from Java's limitation, so there will be no hope for improvement unless

I found a way to directly access camera device? do you think this is feasible? Hope listen to others' comments.

View 3 Replies View Related

Android :: Avoiding Garbage Collection For Smooth 2d Animations

Dec 28, 2009

I'm drawing a rect to a surfaceview. Nothing special, just a test like this, in the surfaceview-extended class:

private int mPosX = 0; private Paint mPaint = new Paint(); Code...

the rect just bounces around the screen. I'm watching DDMS, I still see the garbage collector being called, even with this simple draw loop. There is no other application code being executed.

I'm wondering if it's realistic to expect the gc to not be called at all if we take care to not allocate any objects during our draw loops. I'm trying to extend this example to do some smooth animations, but every once in awhile the gc is called and you can see the drawing stutter. Although none of my application code is allocating any new objects, I don't know what the underlying API is doing inside surfaceview etc, and I doubt we can control that. Just wondering if this is not possible, I'd prefer to abandon this game idea up-front if we can't guarantee smooth animation.

View 5 Replies View Related

Android : OpenGL Garbage Collection - With Direct ByteBuffers

May 20, 2009

Hi, I have discovered while using DDMS that the basic OpenGL system calls in my code are allocating memory and causing the garbage collector to fire! It's not the system calls themselves causing the problem but the use of direct byte buffers to pass data in.

The direct byte buffers I use in calls such as glVertexPointer & glTexCoordPointer lead to java.nio calls to read the byte buffers, leading to objects of type org.apache.harmony.luni.platform.PlatformAddress being created.

These buffers are the same as in the example OpenGL code. I am creating a ByteBuffer using allocateDirect() and then creating an IntBuffer using ByteBuffer.asIntBuffer() to pass data to the OpenGL functions. The problem occurs as the system is reading the buffers.

Is there a way around this? Maybe using something other than direct byte buffers? It seems that using this method, OpenGL code of any complexity (ie a lot of OpenGL system calls in every frame) is doomed to pause a lot. I am aware that these calls should be kept to a minimum, but I still need to use a certain amount of them.

View 9 Replies View Related

Android :: Force Garbage Collection To Happen At Convenient Time?

Apr 15, 2009

I have screen 1 of my app which I want to transition smoothly into screen 2.

I want the transition to be smooth but I don't mind a slight pause before or after the transition. Before the transition I dump a lot of objects that are no longer needed from screen 1.

However, as luck would have it (!), the garbage collection almost always takes place during the transition causing the frame rate to drop and the transition looks terrible :(

Is there a way for me to either force the garbage collection to complete before the transition or delay until after the transition is finished? I have tried System.gc() in various places but it doesn't seem to help performance.

View 2 Replies View Related

Android :: Garbage Collection Infinite Loop - Clamp GC FOR MALLOC Grow Heap

Jul 6, 2010

I have a Service which uploads a big file to a webserver. This works fine on the emulator (android 2.1). But if i run it on a Nexus One Froyo phone it starts out fine. But after a while it is in an infinite GC loop. The whole phone becomes unusable:.........................

View 5 Replies View Related

Android :: One Line Causing Lots Of Garbage Collection.String.format With Float?

Apr 13, 2009

In my ListView, there's one line of code in my ViewBinder that causes lots of garbage collection as I scroll through the list, about every two seconds...

D/dalvikvm(16312): GC freed 13171 objects / 659576 bytes in 162ms D/dalvikvm(16312): GC freed 13122 objects / 654128 bytes in 129ms D/dalvikvm(16312): GC freed 13134 objects / 655416 bytes in 142ms D/dalvikvm(16312): GC freed 13129 objects / 654840 bytes in 129ms D/dalvikvm(16312): GC freed 13149 objects / 655000 bytes in 110ms D/dalvikvm(16312): GC freed 13150 objects / 655720 bytes in 127ms D/dalvikvm(16312): GC freed 13075 objects / 652256 bytes in 111ms D/dalvikvm(16312): GC freed 13232 objects / 659040 bytes in 136ms D/dalvikvm(16312): GC freed 13106 objects / 653920 bytes in 110ms D/dalvikvm(16312): GC freed 13155 objects / 655152 bytes in 110ms

The offending code is here, which formats a price for each item in the list: String price = cursor.getString(columnIndex); final float pricef = Float.parseFloat(price); price = new StringBuffer("$").append(String.format("%. 2f",pricef)).toString(); ((TextView)view).setText(price);

If I comment out the line with String.format, the garbage collection goes away. So what's the "right" way to do this to avoid allocations? That database field holds an unformatted text string which I'm trying to format into proper currency format (example: format "1.5" to "$1.50")

View 9 Replies View Related

Games :: Should I Use Flash Air / Java To Develop Games?

Nov 13, 2010

I'm a beginner android developer and thinking about making a decently big game. I know that Flash air is only available to android 2.2 and future releases, but should I still make the game using Flash? Using Java would imo be so much more difficult and time consuming, but I suppose all android versions would be able to run it. Also, how efficient can android 2.2 run Flash Air? Can a game made in Flash Air run almost as fast as the game made with Java?

View 3 Replies View Related

Games :: Play Java Games From Sd Card On The G1?

Apr 5, 2009

Is there any way to play java games from my sd card on the g1? i could do this with my t mobile wing but i cant figure out how to do it on the g1.

View 4 Replies View Related

Games :: Java Games Support?

Dec 3, 2008

I'm totally lovin' the market and I can't wait to see what else comes along (esp the games). I just have a few simple questions. I couldn't find much info and sorry if I sound newb, but Does the phone in anyway support Java games? Like the gameloft types? I ask cause my last few phones have been touch screen with no buttons and I'm dying to play some older games with the keypad. heh. I've also got a friend with an N96, which brought back memories of the old taco phone I had. Can this phone push out the same kind of power?

View 1 Replies View Related

Android :: Java Sync Games - Synchronized & Wait & Notify

Dec 17, 2009

I'm coming from .NET world, and unfortunately looking Java source with .NET's eyes. Following code is from Android Apps (though not Android specific at all):

private class Worker implements Runnable {
private final Object mLock = new Object();
private Looper mLooper;

Worker(String name) {
Thread t = new Thread(null, this, name);
t.start();
synchronized (mLock) {
while (mLooper == null) {....................

View 4 Replies View Related

Android :: Strange Delays When Doing Wifi Scans

Aug 19, 2010

I have a simple app that just initiates a wifi scan every two seconds and then logs the results. I am observing some strange behaviour, and was wondering if anyone could shed some light. When I start scanning, if the phone (Nexus One running latest Froyo OTA release) is just sitting on my desk (screen on or off, it doesn't matter), I receive the wifi scan results about 800ms after initiating the scan, fairly consistently. At most, it takes a second and a half to receive the results. However, if I get up and start to walk around the building that I'm in, the time between initiating the scan and receiving the result begins to vary greatly. What is interesting is that I start to see a pattern where it will take about 40 seconds to receive results, then I will get three or four results two seconds apart, then it takes 40 seconds to receive the next set of results, then I get three or four results two seconds apart, etc.

I've tried obtaining a wifilock, both the FULL and SCAN ones, and that doesn't help. Same with a partial wakelock. I've also tried setting up a thread that pings the supplicant every second and reports when it is unreachable, and it appears to always be responsive (ie., I never see the report). I thought that maybe the problem was that I am unable to receive the result of scans when I am switching between base stations (which might happen when I move around), but if I manually switch between two different networks, it does not cause a delay in my scans (ie., I can still get the results with only a one second delay while it's associating with the new network). Anyway, for my application, it would be incredibly useful to get wifi results at a fairly consistent rate, and so I was hoping that someone on this list might have some suggestions as to how I can achieve this.

View 2 Replies View Related

Android :: Handcent Launch / Exit Delays?

Dec 27, 2009

I've been getting delays when launching and exiting Handcent...not 100% of the time, but much of the time it takes forever (like >6 seconds) to launch or for my home screen to appear after exiting.

View 7 Replies View Related

Android : Live Stream Latency - Delays In VLC

Apr 13, 2010

We are developing an Android video conferencing application. After examining some already existing live-stream applications , we came to the conclusion that all or almost all existing applications have a delay of 3 to 10 seconds. The application we are developing was tested receiving a video stream on the Android device and the same video stream on VLC at the same time.The result of the test is that VLC shows the same part of the video 2 to 10 seconds earlier than our Android application on the phone(HTC hero) depending on the rtsp link used. we haven't found what is the main cause of the delay and also dont know if it is possible to reduce that delay. In our case, as it comes to video conferencing, the delay should be lower than 2 seconds at least. Do you guys have some information about the cause of the delay or even how to reduce it?

View 5 Replies View Related

Android :: Thread(s) Producing Garbage?

May 27, 2010

I have an app with about 15 threads. Most do mundane tasks and sleep most of their lives. Others collect information and cache it in hashmaps. The hashmaps grow to a moderate size and level out. The number of keys and size of value remains constant, but the contents of the values changes (at 33 keys per second average). When I start my app, I notice the garbage collection interval goes from minutes to once per second, and the amount of garbage is 700k+ each time. In fact as I was writing this, it caused my phone to reboot with an error "Referencetable Overflow". Here's my question: Are there any tricks to identifying which threads are producing the garbage, or even finding out more about what garbage they are producing?

05-26 22:08:57.052 W/dalvikvm( 1031): ReferenceTable overflow (max=512)
05-26 22:08:57.052 W/dalvikvm( 1031): Last 10 entries in JNI local reference table:
05-26 22:08:57.052 W/dalvikvm( 1031): 502: 0x449904a8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 503: 0x4494fda8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 504: 0x44a172c8 cls=Ljava/lang/String; (28 bytes)
05-26 22:08:57.052 W/dalvikvm( 1031): 505: 0x448c7900 cls=Ljava/lang/String; (28 bytes)........

View 2 Replies View Related

Android :: Need To Replace Garbage Keyboard Bundled With 1.6

Feb 11, 2010

Was looking for some guidance here. I need to replace the garbage keyboard bundled with 1.6 for something else. Which in your opinion is the best replacement and why? Maybe some comparisons would help also. Oh, by the way i'm running a mytouch 3g!

View 28 Replies View Related

Android :: Garbage Collector Conservation - Best Practice

Jul 29, 2009

I didn't use much Java before Android so my knowledge concerning the gc is marginal. Now I'm developing a highly physics-based game and therefore I need to do many calculations each time step and many (25) time steps per second. At the moment I'm almost only using local objects (float) in my methods, so I guess they are allocated every time the method is called (which might be, for example, 25*100 = 2500 times a second , for 100 objects with calculations on them). This causes massive activity of the garbage collector like freeing ~10000 objects every 1-2 seconds (taking ~200ms on a real device). Now I really want to optimize that because even there's no noticeable delay due to the GC (and the frame rate is constant), this seems just not well. But I read on many documentations concerning Java optimization, that there is not much to optimize in modern versions of (desktop) Java, because the GC is fast enough. Does this apply to Android, too? Does the compiler optimize anything like frequently, steady allocated objects (like floats)? What would be best practice: keep all local objects and allocate and free them all the time or use class-global objects, even if they are only used inside one particular method (which is bad programming style but conserves GC?

View 5 Replies View Related

Android :: Possible To Stop Droid Garbage Collector?

May 21, 2010

Is there any way to stop the garbage collector for some time?

View 2 Replies View Related

Android :: Glbuffersubdata With An Offset Into Buffer Without Causing Garbage

Aug 1, 2010

I'm trying to update part of a VBO with a call to glBufferSubData(). When I update from the start (0) of my existing shadow buffer, there is no problem, as the buffer starts reading from 0. The following will read 0 to y from the buffer and place it at 0 to y in the VBO: gl.glBufferSubData(GL11.GL_ARRAY_BUFFER, 0, y, mPositionBuffer);

However, if I want to update a portion of the VBO (not from 0) I run into a problem; The following doesn't work, since it will write the values from the start of the buffer (0 to y) into position x to x+y of the VBO:........................

View 1 Replies View Related

Android : Are Primitive Types Garbage Collected In Droid?

Mar 18, 2010

I know this may be a dumb question, but my background is more in c++ and managing my own memory.

I am currently cutting down every single allocation that I can from one of my games to try and reduce the frequency of garbage collection and perceived "lag", so for every variable that I create that is an Object (String for example) I am making sure that I create it before hand in my constructor and not create temporary variables in simple 10 line functions... (I hope that makes sense)

Anyways I was working though it some more tonight and I realized that I a may be completely wrong about my assumption on garbage collection and primitive types (int, boolean, float) are these primitive type variables that I create in a 10 line function that gets called 20 times a second adding to my problem of garbage collection?

View 2 Replies View Related

Android :: Particular Collection Of Code Along With Some XML Files

Jun 4, 2010

I have a particular collection of code along with some XML files that I need to share with every application I will make.

At the moment I can't because as far as I am aware there is no way to do this. This seems like a massive oversight by the development team.

If the code needs changing, I have to change it in every app that I create - and will create in the future.

Are there any ways to share code in android yet? I am using Eclipse for development.

View 3 Replies View Related

Android : Data Collection With Droid Via USB?

Jul 17, 2009

What would be the best way to access the USB as a serial port on a android device (HTC Magic) ?
I am thinking about a OBD-II interface, can I do this on a startdard phone or more likely I'll need a modified firmware ?

View 7 Replies View Related

Android :: Print Integer To Canvas Fast And Without Garbage Collects?

Nov 24, 2010

I have a tight game loop in a separate thread where I paint a lot of things on the canvas.

When I paint the score to the canvas I use the following function code...

When I check allocations in ddms I see that .toString not totally unsurprising allocates a char array on each conversion from an Integer to a String. This array will eventually be claimed by the garbage collect and cause uneven rendering of frames on slow android devices.

Is there a better way of painting integers on a canvas that won't cause new allocations and garbage collects?

View 1 Replies View Related

Media :: Sync Your Music Collection To Android

Jan 8, 2009

Ok before you start salivating and jumping up and down like a hysterical clown, read the following disclaimer

"At the moment you can not do this, but very soon you will. In fact it is being developed as we speak"

Still interested? Read on

Mozilla, our (second) favourite web browser has had an open source media library and player for some time ( called songbird ). The interface looks cunningly similar to i-tunes, and keeping in tradition with mozilla's theme and addon creation the plugins, themes and addons are pouring in.

According the their roadmap support for extrnal USB devices like mp3 players, cellphones and PDA's is coming very soon, in the next development phase. Which means one thing for you and me, the ability to sync our media collection with our G1's

View 3 Replies View Related

Android :: Where To Find Girlson Collection For Phone?

Sep 4, 2010

Now that girls in home, girls on river, etc have been removed from the market can someone tell me where I can find them?

View 2 Replies View Related

Android :: Want Droid Collection Andrew Bell

Aug 14, 2010

Does anyone have any of andrew bells android google mini figurines that they don't want. I'm looking to buy some specific ones.

View 11 Replies View Related

Android :: Trap In TabHost When AsyncTask Delays Set Content View At Activity Startup

Nov 3, 2009

I've got a tab host activity started from a home screen shortcut. When my application starts it downloads information from a server using an AsyncTask. In the onPostExecute method of the AsyncTask I call setContentView to display the TabHost.When I start the homescreen shortcut by tapping on the shortcut using my finger everything works as expected, I download the information from the server and display the TabHost with the information in the tabs. However starting the application by navigating to the shortcut with the mouse wheel and then clicking on the shortcut with the mouse wheel leads to a trap in the framework code as soon as my application starts. This looks like a simple fix since mCurrentView is null at the time that this method is called - can this issue be addressed? Does anyone know of any workarounds?

View 5 Replies View Related

HTC Incredible :: Email Delays Despite Immediate Sounds

May 5, 2010

I have an odd issue. When I get an email, it sounds immediately. But when I go to read the email, it's not on my phone yet. It makes the sound, but does not show any message indication. About a minute or two later, the message shows up.

View 3 Replies View Related

Android :: MotionEvent And KeyEvent Causing Excessive Garbage Collect (GC) Calls

Jan 3, 2010

I'm running into some issues with input events and garbage collection, or more precisely object allocation. I am creating a game and have pretty much got my head around the OpenGL environment. I've digested all the relevant material I could find regarding performance, memory allocation etc (and watched the excellent presentation by Chris Pruett - http://code.google.com/events/io/2009/sessions/WritingRealTimeGamesAn...). I've pretty much eliminated any object allocations after initial setup from my game (which is still in its infancy), but I'm still getting a bunch of GC calls, like this:...........................

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved