Android :: Possible To Stop Droid Garbage Collector?
May 21, 2010Is there any way to stop the garbage collector for some time?
View 2 RepliesIs there any way to stop the garbage collector for some time?
View 2 RepliesI 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 RelatedI 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 RelatedI 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?
I started having an issue a couple days ago (after not making any changes to any settings) where anything with the slightest hint of.bass sounds awful in the car. It sounds fine on headphones, and the same car adapter I use on the DX sounds just fine with other devices through the same speakers. Doesnt matter if I use Pandora or the native music app. What gives? I checked my audio effects settings already and no changes there help. Im baffled because all the things that could be wrong work fine with other devices.
View 7 Replies View RelatedI 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)........
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 RelatedI'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.
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:........................
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.
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.
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);........................
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.
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?
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 RelatedI 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 RelatedIn 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")
My battery keeps on over heating when i charge it. My battery started acting funny this week when i plugged it in to the charger and it would charge stop charge stop continuous. Should i take it up to Verizon and see what they say.
View 13 Replies View RelatedIn my application i have several activities and i want to start background music whenever my *Application* is launched and stop music whenever *Application* is paused or stopped.
View 4 Replies View RelatedOkay when user presses log out button what's supposed to happen is:
Code:
stopService(myIntent);
unbindService(mConnection);
mIsBound = false;
I need to shut down the service on background.Except the service restarts itself over and over again! Even if I kill the program from task manager the service restarts itself. Other programs aren't using the service. when I uninstalled the program the foreground program information popped up indicating it was STILL there(albeit this I solved by rebooting phone).
When user says he's finished with the program 'least he can expect is for the program to stay down rather than keep eating battery by acquiring GPS signal and sending them to server. The program is not intended to be "once you log in you need to Uninstall me and reboot phone to get rid of me!" type of program!
Once started, how can I stop the app from playing.
View 27 Replies View RelatedDoes anyone know the solution to this problem in android?
Can we get any event when a user delete SMS from Android messaging application.
If yes, then how will we intercept Android messaging application.
I know you can 'seekto()' with Mediaplayer... (To start at a certain point)
But does anyone know if there is a way to make a track (the audio playing)... Stop at a certain point?
-or would an if statement on a timer loop have to be used?
I made an application in android and used timer like this. code...
View 1 Replies View RelatedThis drives me nuts. I have the contacts that I want synced via my Android device and my main Gmail account, however I do a lot of buying and selling on CL and I am constantly emailing people who arent in my contacts. However I always end up with email addys that I dont want saved in contacts. How do I stop this from happening?
View 3 Replies View RelatedI am using Android 2.2 (API Level 8). The camera is enabled in the manifest. When I try the camera icon provided by the emulator model, it runs for a few seconds showing a gray box moving around a black and white checkerboard, then dies with the error message...
View 1 Replies View RelatedHow do you stop the Android softkeyboard from displaying completed text in a TextView. It is very important for my application that the spelling is not shown. In 1.6 SDK I made the InputType = VisiblePassword and that seemed to stop it, however this does not appear to work in the 2.1 SDK.
I have already posted my query here, but unfortunately, not getting the required support for this simple query.
I am using a progressbar widget in my application to show the download progress.
In the current state, I am able to manually move the slider back and forth while download is progressing. How can I prevent the manual moving of progressbar, instead it works only based on
progressbar.setProgress(progressbar.getProgress() + 1024); -- currently this works perfect, but I need to prevent the manual moving of progressbar during download.
I recently released an update to my application (about a week ago).
Since then, I've had two emails from users who report that, while updating the app through Market, the installation process gets "stuck" and never finishes. This is after the application has been downloaded. They can't abort the installation.
Did anyone here have similar reports recently?
I am using a class which extends Handler class to update my activity UI.
The code is as follows in side main activity...
But here i am facing one problem that is it is running after closing my application also .
please solve my problem to stop this handler when close this application.