Runtime Error - Failed to allocate a .... byte allocation with .... free bytes

760 views
Skip to first unread message

Jaume Tortosa Vallés

unread,
Sep 18, 2015, 3:11:04 PM9/18/15
to MIT App Inventor Forum
Hello, I'm developer of beta appinventor. I have an app with a lot of screens, and now I'm translating slowly of the ai to ai2. The convert tool of ai2, didn't work correctly for me, so I'm decided to translate all the project. But now I have a problem.

When I'm testing my app, appear this error:

Runtime Error - Failed to allocate a .... byte allocation with .... fre bytes.

This error didn't show in beta appinventor.

Can help me anybody?

Thanks.

SteveJG

unread,
Sep 18, 2015, 3:43:53 PM9/18/15
to MIT App Inventor Forum
You said " I have an app with a lot of screens" ... how many actually?   AI2 apps start to become unstable at 10 screens, so if you have more than 10, that might be the issue.

I have never encountered the error "Runtime Error - Failed to allocate a .... byte allocation with .... fre bytes." that could be a response to too many screens.

To get specific help, you need to share more information about your app Jaume ... screenshots of the blocks for instance or an aia.   We cannot 'see' your app running.  You get the runtime error while testing... does this happen as soon as you try to run the app using Companion on your device or do you get the error while doing something else like trying to change screens or ?

Regards,
Steve

SteveJG

unread,
Sep 18, 2015, 4:46:29 PM9/18/15
to MIT App Inventor Forum
You replied by eMail.  We ask all users to keep the discussion within the Forum.

You said: Hello Steve, my app has 40 screens, in beta appinventor work very good.

I compile the apk, and I install it in my mobile (LG G4 with android 5.1). This error appear when load a screen with a lot for buttons and components.

You can see my beta (ai) app in google play in this link:
https://play.google.com/store/apps/details?id=appinventor.ai_jaumetortosavalles.TPVSimpleBarFree

I attach the error screen in this email.

Thanks for your answer.


Your AI app appears real neat.  great work with AI !


1) 40 Screens...probably impossible with App Inventor 2.  AI2 is a huge improvement over AI Classic, however some things worked in AI that do not work in AI2 for many reasons.  App Inventor 2 apps become UNSTABLE with more than 10 screens (sometimes a developer can get away with a few more screens).  You are going to have to live with the screen limitation constraints by using Horizontal and Vertical layouts as virtual screens and showing and hiding use the Visible property true/false.  We don't know how you use components in your app but guess you could use some components on a single screen to probably give you the flexibility you have on 40.


2) App Inventor apps have issues when many layouts and objects are on a single screen.  You said "error appear when load a screen with a lot for buttons and components"  --possibly your Pedito screen?   The assumption is that screen in particular needs to be redone in a style compatible with the limitations of App Inventor 2.   I imagine you get the error because that page is using a lot of resources (but I do not know).  


3) That the runtime error is when running the app on a device seems to indicate your app is using lots of resources.   Are you using a Fixed screen or a Responsive Screen in AI2?

Some of the issue might be the size of images you store in Media versus the actual displayed images in your app.  App Inventor apps currently have issues resizing large images in Media to small images in the app.  MIT is aware of this and are working on a solution.  The problem seems to be most intense in Android 5+ devices.  The solution for many users is to re-size the Media images using an outside image manipulation tool.     You might try that on the page that goes bad with many buttons with images.


4) Another issue may be how you are changing screens safely.  There was no big issue using AI, however in AI2 developers have to use one of two methods...you seem to require the TribbleHunter method.  http://puravidaapps.com/tribblehunter.php     What might be giving you problems is how you change screens.   If you do not close a screen you leave safely, freeing system memory, eventually the app will run out of system memory.  This is a huge possibility in your case.


Advice is free.  Take a minute to review and see what might help to get your AI Classic to work in AI2.


Regards,

Steve

Jaume Tortosa Vallés

unread,
Sep 18, 2015, 5:56:05 PM9/18/15
to MIT App Inventor Forum
Thanks Steve.

I'm sorry for reply your email.

The runtime error appears when the app try to load more than one image for the product buttons in the main screen. As you see, my app is a POS, and the user can select an image for their products.

If the products hasn't any image, the screen is loaded correctly, but if I select more than one image, the error appear. With one image don't crash.

Do you understand me?

SteveJG

unread,
Sep 18, 2015, 6:06:20 PM9/18/15
to mitappinv...@googlegroups.com
I understand.    How large are the product images (in pixels)?     How large is the space the image is displayed (in pixels)?      if the product image is 1000 x 300 pixels and the display image is 100 x 30 pixels, the app is going to crash.   Try making the product images (in pixels)  =   display size and when you add an image, perhaps the app will not get the error?   Try it.   See  issue 3 in my prior post.

Also, please confirm that you are closing screens using the TribbleHunter method when you leave them to go to another screen.   If you do not close the screens properly, you app is going to crash.

Ismael Acien

unread,
Sep 19, 2015, 3:38:27 AM9/19/15
to MIT App Inventor Forum
Hola Jaume, este es el modo que utilizo para navegar entre Screens

ejemplo.png

Jaume Tortosa Vallés

unread,
Sep 19, 2015, 4:42:46 AM9/19/15
to MIT App Inventor Forum
Gracias Ismael, es mas o menos lo que hago cuando cierro una pantalla, a veces lo hago así, otras utilizo un reloj para cerrarla. El problema está más bien cuando el programa está accediendo a disco para cargar varias imágenes en distintos botones, cuando carga una sola imagen en un botón funciona, cuando va a cargar otra imagen en otro botón aparece el error Runtime Error memoria..... 

Creo que es problema de Ai2, esto nunca ha pasado con la Ai (beta). Mi app en beta siempre ha estado estable, he utilizado casi todos los componentes del appinventor de forma satisfactoria, nunca he entendido porque han hecho Ai2, se supone que es para mejorar pero luego te das cuenta que con Ai (beta) se trabajaba mejor y falla menos... no se, ahora mismo estoy desilusionado con el proyecto, no se si continuar o buscar otro lenguaje.

¿Se podría exportar un proyecto aia a Android Studio?

Saludos y gracias.

Ismael Acien

unread,
Sep 19, 2015, 8:31:06 AM9/19/15
to MIT App Inventor Forum
De lo que se de estos errores que empezaron el 15 de agosto es que mi apk no funcionaba en ninguno de los móviles de que dispongo para hacer pruebas, ni tan siquiera un ejemplo simple de una pantalla, por recomendación para que funcionara recorté tamaño de imágenes y limité pantallas, pero seguía sin funcionar. Casi a la par, llegó un parche que solucionaba esto en parte y voilà ahora me funciona en todos lo móviles que dispongo, pero me llegan errores de play store de otros usuarios que disponen de móviles que aún siguen reproduciendo estos mensajes de error y creo que es por motivos de velocidad de procesador. Por mi parte creo que ya lo he hecho todo y ya solo espero que depuren mejor esta fabulosa herramienta y sobre todo que den el aviso de solucionado para volver a empaquetar el apk y restituirlo en el play store. Creo haber visto por el foro un Ai2 offline que si soportaría el aia y sin fallos.

Jaume Tortosa Vallés

unread,
Sep 21, 2015, 5:32:08 AM9/21/15
to MIT App Inventor Forum
Hello Steve,

I'm doing tests, and I think the error is in the function "Set Button.image { component, image }", when my app is loading this function 3 times (This funciont is in a bucle), the app is crashed with this error. The images for the buttons are 440x440 pixels, and these images are created with a canvas componentes and are saved in a folder in the device. 

I think that this error is when the app try to access to more files in the device or when try to load more images in buttons components. I'm not sure, but I'm trying to explain you, so the developers of appinventor can improve it.

I'm sorry by my english.

Regards.

SteveJG

unread,
Sep 21, 2015, 8:32:13 AM9/21/15
to MIT App Inventor Forum
The problem is probably that "The images for the buttons are 440x440 pixels".   What size are the buttons you are placing these images?      Make the images the same size as the button and the problem will probably go away.  Without seeing your source code, we do not know for sure.

Earlier, you were told there is an issue in version 1.45 about using large images and shrinking them to small images as you are doing with your buttons.  Shrinking lots of images no longer works in AI until MIT finds a fix.  The large images you are using are probably the problem in your case.  MIT is aware of this problem.  It is very difficult for them the change this behavior and it has a high priority..   You do not have to wait for MIT to fix the problem if you make the 440x440 images smaller in Media, perhaps 50 x 50 pixels.

Since you have not posted an aia for the MIT technical staff to review, I suggest you make a copy of your Project.    Now with the copy, replace all your images with smaller versions of the images that are approximately the size of your buttons to images that are png images that are exactly the size of your buttons.  This probably will fix the problem in your Project.  Using smaller images has helped many other developers.  Try it.

The problem is not in the set button image.   App Inventor works differently than App Inventor Classic; developers have to accept that AI2 projects will not run exactly like AI projects.

Regards,
Steve

Jaume Tortosa Vallés

unread,
Sep 21, 2015, 12:50:48 PM9/21/15
to MIT App Inventor Forum
Hi Steve, you're right. I changed the image size to 256x256 and load the images in the buttons correctly.

I've noticed that the canvas component creates a 4 times bigger image pixels defined in the canvas, for example, if the canvas is 100x100 when storing the image, the image is 400x400. So I modified the canvas to 64x64 pixels to create images of 256x256 for buttons.

Greetings and thanks.

Reply all
Reply to author
Forward
0 new messages