[J2ME]How to avoid memory fragmentation

D

DNass

I have developped a mobile app,
and I'm actually trying to deploy this app
on a Sony Ericsson T610.
On the emulator it works just fine, but on the mobile
I have this system error message saying "this application is
using too much memory", I know that the app uses about 150k of RAM
and the mobile has 260 k
there for I thougth it was due to
a problem with the memory fragmentation.
I was wondering if somebody here had the same problems
and if yes could she/he share his experience

Thx in advance

PS: the app make connections to server via http
to retreive informations (text and/or images)
 
J

JScoobyCed

DNass said:
I have this system error message saying "this application is
using too much memory", I know that the app uses about 150k of RAM
and the mobile has 260 k

If the application has pictures, try to decrease their sizes. This will
help lowering the app size. Then use an obfuscator to optimize the byte
code and reduce again the size.
Now if the file received by HTTP is bigger than the available memory, it
might crash the app too.

JScoobyCed
 
D

DNass

when I see the content length of the file received and the amount
of free memory (with the method Runtime.getRuntime().freeMemory()) it seems
that
my app can handle the response but then I have the error message.

Thank you JScoobyCed, I am going to try to
obfuscate the app and let you know.


JScoobyCed said:
If the application has pictures, try to decrease their sizes. This will
help lowering the app size. Then use an obfuscator to optimize the byte
code and reduce again the size.
Now if the file received by HTTP is bigger than the available memory, it
might crash the app too.

JScoobyCed

DNass
 
D

DNass

unfortunatly obfuscating the bytecode isn't enougth :(
I still thing it has something to do with memory fragmentation
but don't know how/what to change so that this app becomes stable

thanks anyway :)
 
D

Darryl L. Pierce

DNass said:
I have developped a mobile app,
and I'm actually trying to deploy this app
on a Sony Ericsson T610.
On the emulator it works just fine, but on the mobile
I have this system error message saying "this application is
using too much memory", I know that the app uses about 150k of RAM
and the mobile has 260 k
there for I thougth it was due to
a problem with the memory fragmentation.
I was wondering if somebody here had the same problems
and if yes could she/he share his experience

Thx in advance

PS: the app make connections to server via http
to retreive informations (text and/or images)

The mobile may have 260k, but remember that some of that is going to be
taken up by the ROM image of your application. So, if you're using 150k
of heap, you're only leaving 110k for the ROM image and stack space,
which isn't very much at all. Emulators based on the WTK always have
512k for their heap so you're hard pressed to use up their memory.

I would say first off go through your code and reduce that heap usage.
What are you using 150k for? Seems that you should put some of that data
into RMS or else let it go 'cause that's way too much for almost any
handset to handle.
 
D

Darryl L. Pierce

JScoobyCed said:
If the application has pictures, try to decrease their sizes. This will
help lowering the app size. Then use an obfuscator to optimize the byte
code and reduce again the size.

Very good point! The one I would recommend is Proguard. It's free and
does a bang up job of shrinking the size of MIDlet suites.
 
D

Darryl L. Pierce

DNass said:
when I see the content length of the file received and the amount
of free memory (with the method Runtime.getRuntime().freeMemory()) it seems
that
my app can handle the response but then I have the error message.

But the data received has to be wrapped in HTTP buffers (which take up
memory) and then transferred to a byte array (which takes up some more
memory). In the process, you may even end up having the data doubled in
memory if it's copied from the HTTP buffer to the byte array, rather
than being passed completely.

All in all, the tip is to only accept data that's smaller than half of
available memory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,277
Latest member
VytoKetoReview

Latest Threads

Top