You Are Here:

Community: Developer Discussion Boards

#1 Old Are repeated calls to Image.getGraphics allowed ? - 2003-04-06, 22:17

Join Date: Apr 2003
Posts: 4
hskopp
Offline
Registered User
If you call repeatedly the method Image.getGraphics() of a single image in the Series 60 MIDL implementation, the method throws an ArrayIndexOutOfBoundsException at some time.

Is this a standard conforming behavior?
Is it not allowed to call this method more than a few times?

Example:

In the following method, the call img.getGraphics() throws the exception when y=18. Is reproduceable with the Series 60 MIDL emulator and on the Nokia 3650 device. All other emulators I have tested do not throw an exception.

private void repaintImage() {
int sizey = getHeight();
int sizex = getWidth();
Image img = Image.createImage(sizex, sizey);
for(int y=0;y<sizey;y++) {
Graphics g = img.getGraphics();
g.setColor(208);
g.drawLine(57, y, 57, y);
}
}

Moving the line 'Graphics g = img.getGraphics();' out of the loop
removes the exception.

The API documentation just says that at each call a new object is created at each call of Image.getGraphics() and that the object has an indefinite lifetime. Though I would expect that unused objects are garbage collected...

Hans
Reply With Quote

#2 Old 2003-04-07, 11:19

Join Date: Mar 2003
Posts: 112
Location: Helsinki.FI
Send a message via AIM to tinkezione Send a message via Yahoo to tinkezione
tinkezione
Offline
Regular Contributor
Hi Hans,

please refer to our technical note about memory issues with current Series 60 devices. Due to heap memory management devices may run into weird problems if memory consuming calls (such as getGraphics() is as it will always create a new Graphics instance) are being made extensively. I believe this seemingly non-relating ArrayIndexOutOfBoundsException relates to this also.

You can find the technical note from http://www.forum.nokia.com/ -> Java -> Documents and there it is.

Kind regards,
Tinke / FN
Reply With Quote

#3 Old 2003-04-08, 18:51

Join Date: Apr 2003
Posts: 4
hskopp
Offline
Registered User
Thanks Tinke,

I agree that the fix described in this document might cause the exception.

Best regards,

Hans
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: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X 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