Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Image loading/holding optimizations  (Read 2242 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Duke




Java games rock!


« Posted 2005-02-14 11:07:17 »

i have quite big problems to get a heap overflow in control.
the reason is the large amount of graphics data (spoken in the dimensions of series40).

its an animated board game so there are no levels or stages where gfx-sets change, so most images are needed at the same time.
the hard problems are the animation-strips for both players:
all frames for one player are stored in one file. the frames are all in one row and packed together as close as possible.
nevertheless one character image has a dimension of 750x22px (x2 for each).
beside the background tiles these big images are the heap killers. i tried to split them into smaller files to load some animations only on demand (e.g. victory pose) but loading an image during game causes some heavy lag. besides the garbage collector often reacts very slow (even called).

any hints or techniques are very welcomed.
Offline wooD

Senior Newbie




J2ME Developer


« Reply #1 - Posted 2005-02-14 13:23:56 »

I think your only choice is a different set of art for the under powered phones. Essentially a different app.  Something with smaller characters and possibly less frames per animation.

Hopefully in doing something like this you could keep a lot of the existing code, but it would still require a heavy port and a splitting of the source.

Wood

Offline Serethos

Junior Duke




Java games rock!


« Reply #2 - Posted 2005-02-16 05:46:14 »

sadly, these at currently *are* the lowe res versions  :-/
im doing porting for about 25 phones so code splitting has already happened (though i really, really hate it)

after experimenting a while with memory optimizing i noticed big differences in which order objects get loaded. it seems that heap fragmentation is a serious problem.

to demonstrate my problem:
the game has two splash screens where the resources (bg gfx, the sprites with big animation strips, and some text strings) get loaded. because the heap got an overflow i tried to load some things later, earlier or whatever.

the only time, i got all working (and now i know that it is possible to get the game work with the existing artwork) was to load text and some gfx while displaying splash, enter the main menu and then load via button press(!) first the bg then the sprites  Grin

i really thought that it is better to load big memory chunk at the beginning of the midlet, but it seems that im wrong ...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wooD

Senior Newbie




J2ME Developer


« Reply #3 - Posted 2005-02-16 13:28:19 »

One thing I do to limit this is limiting the use of dynamic variables. My games typically have no more than four class files and all my data is stored in arrays. I know it's arcane, but it does relieve a lot of these problems on underpowered phones.

The classes on my last game were: Main (which included a network thread), Data, Canvas (which included an animation/tick thread), and Menu.  I have my own custom menu system because the List class requires a new instance for every menu. I like having one instance and repopulating it and it uses arrays internally.

I have some instances where I have to use strings, I try to limit them as much as possible. I try to keep most strings static final, but there is always the case where you need to concatinate two strings and I typically don't use +, I create a new StringBuffer, just so I know exactly what is happening, not relying on a translation. That's typically the only dynamic allocation I allow in my games. Everything else is locked down up front.

Quote
im doing porting for about 25 phones so code splitting has already happened (though i really, really hate it)

<rant>
This is actually the worst possible development scenario I could possibly imagine and I hate it too. I don't think Sun really cares though? Conditional compilation (#ifdef) would tend to make life much much easier, but that seems to be taboo to even mention. Sort of like saying the Emperor isn't wearing any cloths and Java is so portable that conditional compiliation has no place in such a perfect system.  That said, I'm sure I could build some sort of Ant system to preprocess the conditional stuff for me, but as I've said in earlier posts, I'm lazy and that sort of Ant system would require a ton of work. Especially to get it front ended on WTK which I use for my final builds. Just the thought hurts my brain.

I noticed recently that NetBeans has some sort of code splitting management system to make this easier. Seemed like a sledgehammer to drive a carpet nail that conditional compilation would easily solve.
</rant>

Wood

Offline shmoove

Junior Duke




Doh!


« Reply #4 - Posted 2005-02-16 15:12:29 »

Quote
Conditional compilation (#ifdef) would tend to make life much much easier, but that seems to be taboo to even mention. Sort of like saying the Emperor isn't wearing any cloths and Java is so portable that conditional compiliation has no place in such a perfect system.  That said, I'm sure I could build some sort of Ant system to preprocess the conditional stuff for me, but as I've said in earlier posts, I'm lazy and that sort of Ant system would require a ton of work.

I gather you haven't heard of Antenna?

Conditional compilation might be evil, but with J2ME it's a necessary evil.

shmoove
Offline Abuse

JGO Knight


Medals: 13


falling into the abyss of reality


« Reply #5 - Posted 2005-02-16 16:38:46 »

*shudder*

In my experience precompilers are often abused, and used in scenarios that they are quite unnecessary.

A good build process, with a complete common source tree, and device specific classes overwriting any necessary classes from common - tends to give a clearer, more portable code base.

i.e.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
gamename/
      src/
            common/
                  some.class
                  other.class
                  etc.class
            samsung_d500/  
                  other.class
            sonyericsson_k700i/
                  other.class
                  etc.class



A single source tree, with precompiler statements becomes unwieldy when it has been ported to a large number of handsets (above 10-15 ports the precompiler statements start to count for more lines of code than the game itself does!)

It also adds the risk that making a modification to the code used by 1 port, could potencially break *any* of the other ports.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline wooD

Senior Newbie




J2ME Developer


« Reply #6 - Posted 2005-02-16 19:50:13 »

Both systems are bad and I was not trying to state what was best. I would personally like to use a precompiler as I think it is much better when you have design changes late in the process.  For long term both methods are just plain broken and subject to all sorts of human errors.

Wood

Offline Serethos

Junior Duke




Java games rock!


« Reply #7 - Posted 2005-02-17 10:48:15 »

first i have to say that we are using antenna here in comination with a self-writte build system for generic resource management.
looking at the overall dissatisfying j2me development (a good  development environment would only patch the bad device implementations) i can really live with preprocessing statements. the big problem with antenna is its lack of (future) features:
i would give my motorola v525 for the use of variables within the statements (no, i wouldnt really .. =)

but the game architecture is a much bigger probelem: at first i really tried to hold the number of classes and instances down. but with more incoming protings you really need some generic solutions (tool classes) to keep the development time down.
for example, i cant hardcode every change of textpassages or language porting. so i had to write a class which works hand in hand with the build system, loads the text resource and formats it so that it fits the screen of the actual device.
though you can really save some heap avoid such things i noticed that the monster part goes to loaded graphics.

i cant really trust the memory profiler from nokia but to give a relation, the whole game without gfx needs about 55kb of heap. in difference there comes an overload of 130kb of images..
Offline Fraggle

Senior Newbie




Java is Great!


« Reply #8 - Posted 2005-02-18 15:44:18 »

Hi,

I work for a company building specifically multiplayers j2me and Doja games.
After a lot of experiments (antenna etc..), we found better to use a combinaison of:
- A in-house ant-task code precompiler (able to use simple logic like "var1 and|or var2") that comment/uncomment code based on enabled vars.
- A ressources_by_device directory system.
- A Custom ant script (preparse-build-dist-push-emul).

All of thems under eclipse directly.
It's not the best but it allow fast build time (10-20 seconds) and also it push using webdav (common-vfs project ant tasks) to the developpement server.
Finally, we have a shell script on the server that everybody can call to sync dev & prod (rsync based).

The precompiler Ant Task should be released on Sourceforge very soon (project: "Satori"), I hope someone will find it useful.

Was my 2 cents, :-)

Seb

Build multiplayers mobile java game for a living.
Offline Serethos

Junior Duke




Java games rock!


« Reply #9 - Posted 2005-02-21 06:43:46 »

an antenna precompiler. sounds very interesting. because antenaa does not seem to be updated very often i really would like to change to another system.
please post some notice when your system is available
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline shmoove

Junior Duke




Doh!


« Reply #10 - Posted 2005-02-21 07:53:29 »

Quote
because antenaa does not seem to be updated very often i really would like to change to another system.

J2ME Polish gets updated quite often.

shmoove
Offline Serethos

Junior Duke




Java games rock!


« Reply #11 - Posted 2005-02-21 08:49:25 »

sure, but polish needs to be licensed for commercial use  Grin
Offline shmoove

Junior Duke




Doh!


« Reply #12 - Posted 2005-02-21 10:01:52 »

Only if you include one of it's libraries in your application. If you just use it as a build environment I don't think you need to get a license.

shmoove
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (59 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!