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.

Android : Latency due to Garbage collection on on PrevFrame


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 :: 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 : 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 :: 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);........................

View 3 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

Android :: Low Latency Audio Api?

Sep 19, 2009

What are my options for playing simultaneous audio on an Android device with the least amount of latency? Am I going to get anything half decent out of the canned SDK, or is that asking too much? The documentation claims that the SoundPool class is capable of playing multiple sounds simultaneously with relatively good performance, but after running some tests in the emulator and on a physical device it seems pretty weak. Is there maybe a trick to it, or do I have to go to a much lower level api for this kind of thing? I've tried using a single sound pool with multiple samples loaded, and I've tried multiple sound pools each managing a single sample. I'm preloading everything, so that when I attempt to play back I have no additional code being executed other than the call to SoundPool.play().

View 2 Replies View Related

Android :: Latency When Getting Sensor Data From Phone?

Mar 9, 2010

I am working on a project using HTC magic which requires the data from the electronic compass, including both the accelerometer and magnetic sensor. But I find that there is a significant latency between the move of the phone and the trigger of the sensorChanged event. In other word, the acceleration and magnetic data obtained from sensor are updated about half of a second after my motion. And I have several questions about the problem as follow. Are the orientation data computed by the acceleration and magnetic data? Or are there a physical sensor for orientation? Does the latency result from the android API (using the event) or the physical limitation of the electronic compass? It is said that the model of the electronic compass is AK8976A from Asahi Kasei. Does anybody have the datasheet or know the frequency of the sampling? Any idea to improve the real-time experience?

View 1 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 : Latency On Mobile Networks / GPRS - 3G?

Jul 8, 2009

I am planning to give mobile phone development a shot and was thinking about making some simple multiplayer games. I know latency over local wifi is probably fine but what are the issues with latency over GPRS/3G?

I've searched and the best I've seen is someone saying it was 'high', without presenting any concrete numbers. I suppose latency fluctuations are important as well - does anyone have any info on this?

View 2 Replies View Related

Android :: Difficulty Of Making Low Latency Audio Apps In Phone?

Apr 12, 2010

Despite everything I have read about the difficulty of making low latency audio apps in Android, I am giving it a shot. To start, I loaded each note in an octave into a SoundPool, and then looped through each note that was to be played on that beat and called play(). This didn't even come close to being accurate enough for me, and got especially bad if a lot of notes were being played at once.

From what I read, the only way to do something like this is to mix the audio yourself, though I am not entirely sure how to go about this. My initial thought is that for each beat, I could precompute the sound the sound that is to be played (i.e., combine the wav's), and then pass that stream to an AudioTrack when it is time to be played.

Are there any good examples out there for how to mix audio like this, or libraries I could use to do this for me? How have coders of other music apps dealt with this?

View 8 Replies View Related

Android :: Low Level Audio - Latency In SoundPool - AudioTrack For Real Time

Oct 26, 2009

I first have to say that I'm biased, 'cus I like to write music apps (like music generation apps). However, this affects games as well. It's somewhat disappointing how OpenGL has made it into the NDK now but there isn't any NDK methods to get to sound to have faster access. Over the weekend I did some more testing and if you make a "drum" app, for example, and play the sound using either SoundPool or AudioTrack, you will get about a 100ms delay buffer, which is clearly audible (gap).

I made a test app where when you touch the screen, upon the DOWN event, it would play a short sound (like a drum sound). It clearly was not real time responsive or even close - you could hear the delay. I'd be interested to know if anyone who has made a game has any trouble with sounds? It seems like they aren't going to really trigger real time enough if you use SoundPool, for example. Am I completely wrong? Seems like your game is going to perform an action, play a sound, but the sound will have latency which I would think would throw off the game a bit..................

View 12 Replies View Related

Android :: 3434 (audio Latency) - Music Applike NanoStudio For IPhone

Sep 29, 2010

This might not be a big deal to most but today, I went to the Android market looking for a music app, something like NanoStudio for iPhone. I found a lot of 2nd rate loop creation synth nonsense. After trying different free versions of paid software I asked myself "why are there no good music apps for Android?"

I emailed the creators of NanoStudio to ask if there are any plans to release an Android version of their software. here is the reply: "Not until they get their act together with audio latency, no. Shame really because NanoStudio's written to be cross platform" This greatly disappointed me. I am a music producer going on 10 years (hip hop, Trip hop, Electronic, etc..) so you can understand my interest in this issue. iphone, iPod have amazing music apps of this sort. Android has nothing close.

View 12 Replies View Related

Samsung Vibrant :: Audio Latency (3434)

Oct 10, 2010

If the Mods decide to delete this and direct you to the OP then thats fine. I just want to spread awareness if this issue. This might not be a big deal to most but I went to the Android market looking for a music app, something like NanoStudio for iPhone. I found a lot of 2nd rate loop creation synth nonsense. After trying different free versions of paid software I asked myself "why are there no good music apps for Android?"

I emailed the creators of NanoStudio to ask if there are any plans to release an Android version of their software. here is the reply: "Not until they get their act together with audio latency, no. Shame really because NanoStudio's written to be cross platform" This greatly disappointed me. I am a music producer going on 10 years (hip hop, Trip hop, Electronic, etc..) so you can understand my interest in this issue. iphone, iPod have amazing music apps of this sort. Android has nothing close.

View 2 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 :: 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

Android :: Itemized Overlays - Not Drawing Collection But Refreshing?

Apr 22, 2010

I'm trying to write code that draws accuracy circles around a gps location based on a time param. I have no problem setting up the GPS, or of calculating how to draw the circles.What's been killing me is that the Overlays always overwrite one another.So I can never have more than one circle.I've looked at all the examples and tutorials online but they seem to be obsessed with putting in icons or with Drawing from some database or array.If I understood correctly I should be able to do itemizedoverlays and just draw as i go without having to track each readout in an array.

View 9 Replies View Related







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