You Are Here:

Community: Developer Discussion Boards

#1 Old Memory issues s40 - 2004-01-29, 10:13

Join Date: Aug 2003
Posts: 127
melas21
Offline
Regular Contributor
Hi there
After writing a game on s60 i tried to modified it to run on s40 but still i can't manage to get the Garbage collector to free memory. Example:
Image bigPng = Image.createImage(.....);

.....
.....
bigPng = null;
System.gc();


Whats wrong???
MChmielewski
Reply With Quote

#2 Old 2004-01-29, 11:05

Join Date: Mar 2003
Posts: 118
Location: Rotterdam, Holland
remonvv
Offline
Regular Contributor
Image resources arent necessarily freed upon garbage collection. Note that garbage collection only makes sure objects that cant be referenced from any live thread are cleaned up. It is the responsibility of the platform/system to clean up resources such as graphics contexts etc., not the VM's. This said, it should theoratically clean those resources up reasonably quick after gc-ing. Although i have to admit i never ever used a single System.gc() in my code and never run into such memory problems, and i have made quite a few graphically intensive apps.
Reply With Quote

#3 Old 2004-01-29, 15:15

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
Since the image data is held in the Java heap, gc'ing should clear it once it is unreachable. In fact, if you subsequently need more memory that is "free", gc should occur anyway. Have you checked the free memory before and after gc'ing? Will freeing this image release enough memory for whatever you want next?

Graham.
Reply With Quote

#4 Old Next question? - 2004-01-29, 17:21

Join Date: Aug 2003
Posts: 127
melas21
Offline
Regular Contributor
This midlet is a game so it needs some graphics objects. I load them from PNG files and many times since i started writing games i had problems with the OutOfMemory Exception especially when You choose another option from the main menu Such as Info about the game or Score board etc. So always after exiting to menu i call a cleanUp function to sweep the garbage but this does not help. When i test my game on nokia emulator i use extendet view of memory and register any changes. Do You know better way to closely inspect Your midllets memory needs???
If so write to me please.

Mchmiel
Reply With Quote

#5 Old 2004-01-29, 18:47

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
You can use Runtime.freeMemory() to find out how much memory is available. (But this is the total, not the largest free block, so you may not be able to use this much in one go if memory is fragmented.)

Graham.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d18645X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ