cello
Full Member
Offline
Posts: 143
Re: Applet: java.lang.OutOfMemoryError
Reply #1 - Jan 14th , 2006, 6:44pm
In general Java is designed to avoid massive amounts of memory being allocated at one time, while you might want to do this, in general you can optimize your code considerably if you take certain factors into account. For starters you should break the earth images into smaller pieces, and load them individually as needed. After all, you can never see more than half of the map at any one time. Then you can be even more clever if you calculate what the actual resolution of the polygons is, then load the appropriate low/med/high resolution based on what they can actually see. That is, if you're zoomed out to see the entire globe on the applet you have now, you'll never see more than the 2048 detail (assuming 1024 is displayed at a time, and the applet is less than 1024 pixels wide). If you zoom in, you're only seeing part of the globe, so you should only load the texture pieces that are visible. A good example of this in action would be Google Earth. If it actually loaded the entire globe at one time, your computer would hang. While eventually computers will be able to handle it, the optimizations above offer zero loss of quality (it may actually increase quality because you will be mimicking a mip-map technique) while increasing speed and saving resources for doing other things. On a side note, abug: Whenever I hit a key on the applet, the globe repositions temporarily before restoring.