Forced Close on second start of app

COBRASoft

Active Member
Licensed User
Longtime User
Hi,

Can somebody help me out here? When I start my app the second time, I get a forced close :(. I've included the log, hopefully it will help...

B4X:
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=q2c.m4a/.main bnds=[120,526][240,676] } from pid 423


** Activity (main) Create, isFirst = false **


GC_CONCURRENT freed 1119K, 54% free 3662K/7943K, external 23165K/23907K, paused 2ms+2ms


GC_EXTERNAL_ALLOC freed 24K, 55% free 3643K/7943K, external 24231K/26279K, paused 24ms


1168128-byte external allocation too large for this process.
VM won't let us allocate 1168128 bytes


GC_FOR_MALLOC freed <1K, 55% free 3642K/7943K, external 24231K/26279K, paused 16ms
Shutting down VM
threadid=1: thread exiting with uncaught exception (group=0x2aac8578)


FATAL EXCEPTION: main
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
    at android.graphics.Bitmap.nativeCreate(Native Method)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:71)
    at q2c.m4a.main._createstep_street(main.java:2847)
    at q2c.m4a.main._activity_create(main.java:377)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:113)
    at q2c.m4a.main.afterFirstLayout(main.java:84)
    at q2c.m4a.main.access$100(main.java:16)
    at q2c.m4a.main$WaitForLayout.run(main.java:72)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3701)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
    at dalvik.system.NativeStart.main(Native Method)
  Force finishing activity q2c.m4a/.main
Activity pause timeout for HistoryRecord{2afcd748 q2c.m4a/.main}

Greetings,
Sigurd
 

COBRASoft

Active Member
Licensed User
Longtime User
Ok Erel, that explains a lot (stupid me :)).

So, BitmapMutable implemented, 1 canvas used for almost everything, conversion to String will be obsolete thanks to a custom http handler written for our webservice.

Next question to improve it all... HTTPUtils used from another thread and in a service. This to keep my app responsive and the upload/download always working, event if the app is paused. Any more advice or sample on this?
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
Yes Erel, I know this, but the problem is I need to 'wait' for the response for every uploaded picture (POST). My app needs to stay responsive at the same time, so requesting a list through POST has to keep working while uploading the pictures.

I was thinking to make a seperate (service) app which runs at boot and restarts itself every 5 minutes or so. I will put all needed data in a small SQLite database from the main app. The service can go through this database and upload pictures as they 'arrive' in the database.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Yes Erel, I know this, but the problem is I need to 'wait' for the response for every uploaded picture (POST). My app needs to stay responsive at the same time, so requesting a list through POST has to keep working while uploading the pictures.
So you are saying you have two kinds of requests going on at the same time?
One higher priority POST requests that fetch a list, and another low priority background picture uploads?
In that case I would suggest using 2 HttpUtils, one for background and one for foreground.
Regardless, your UI will never be unresponsive, but the delivery of data returned will lag.
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
Yes, you got it :).

It goes a bit further, when the app is stopped by the user (or crashed), the service has to continue with uploading them (very important). That's why I would like to make a seperate app just for this. Good idea or overkill?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Yes, you got it :).

It goes a bit further, when the app is stopped by the user (or crashed), the service has to continue with uploading them (very important). That's why I would like to make a seperate app just for this. Good idea or overkill?

The service always works in the background. Unless the user kills it with a task manager or it crashes it will keep running. I think you are safe to use a single app with multiple services.
On the other hand, a separate app can improve reliability and resolve some memory issues.
 
Upvote 0
Top