'OutOfMemoryError' question. thanks

hey guys,
i'm using the NetBean 4.1 to write a simple program, which can load an image and modify it to be green scale image. i want to display the green scale image in original size (display in scrollpane) and on-screen size (resize the image and display in a JLabel ).
my problem is that i only can display the green scale image in either original size or on-screen size. otherwise, the "OutOfMemoryError: Java heap space" appeared.
i am wondering there is any way i can remove the image from the memory when i close original size image window / on-screen size image window?
here is part of my code:
=====================================================
//display the original size of greenscale image
int gsArawWidth;
int gsArawHeight;
// 'image' is the image has been loaded
gsArawWidth = image.getWidth(null);
gsArawHeight = image.getHeight(null);
gsApix = new int[gsArawWidth * gsArawHeight];
try {
PixelGrabber gsApgObj = new PixelGrabber (
image, 0, 0, gsArawWidth, gsArawHeight, gsApix, 0,
gsArawWidth);
if (gsApgObj.grabPixels() && (gsApgObj.getStatus() &
ImageObserver.ALLBITS) != 0) {
for(int cnt = 0; cnt < (gsArawWidth * gsArawHeight); cnt ++) {
gsApix[cnt] = gsApix[cnt] & 0xFF00FF00;
} catch(InterruptedException e) { System.out.println(e);
gsAmodImage = this.createImage(new MemoryImageSource(
gsArawWidth, gsArawHeight, gsApix, 0, gsArawWidth));
JFrame gsAframe = new JFrame("Original size of greenscale image");
gsAframe.setDefaultCloseOperation(gsAframe.DISPOSE_ON_CLOSE);
Icon gsAicon = new ImageIcon(gsAmodImage);
JLabel gsAScrollLabel = new JLabel(gsAicon);
JScrollPane gsAscrollPane = new JScrollPane();
gsAscrollPane.setViewportView(gsAScrollLabel);
gsAframe.getContentPane().add(gsAscrollPane, BorderLayout.CENTER);
gsAframe.setSize(705, 553); //set new window's size
gsAframe.setLocation(0,100); //set new window's location
gsAframe.setVisible(true);
//display the resized greenscale image
int gsBrawWidth;
int gsBrawHeight;
gsBrawWidth = image.getWidth(null);
gsBrawHeight = image.getHeight(null);
gsBpix = new int[gsBrawWidth * gsBrawHeight];
try {
PixelGrabber gsBpgObj = new PixelGrabber (
image, 0, 0, gsBrawWidth, gsBrawHeight, gsBpix, 0, gsBrawWidth);
//make sure the image has been loaded fully
if (gsBpgObj.grabPixels() && (gsBpgObj.getStatus() &
ImageObserver.ALLBITS) != 0) {
for(int cnt = 0; cnt < (gsBrawWidth * gsBrawHeight); cnt ++) {
gsBpix[cnt] = gsBpix[cnt] & 0xFF00FF00;
} catch(InterruptedException e) { System.out.println(e);
gsBmodImage = this.createImage(new MemoryImageSource(
gsBrawWidth, gsBrawHeight, gsBpix, 0, gsBrawWidth));
int gsBmaxEdge = 600;
double gsBscale = (double) gsBmaxEdge / (double) gsBmodImage.getWidth(null);
if (gsBmodImage.getWidth(null) < gsBmodImage.getHeight(null)) {
gsBscale = (double) gsBmaxEdge / (double) gsBmodImage.getHeight(null);
int gsBscaledW = (int) (gsBscale * gsBmodImage.getWidth(null));
int gsBscaledH = (int) (gsBscale * gsBmodImage.getHeight(null));
gsBnewimage = gsBmodImage.getScaledInstance(gsBscaledW ,
gsBscaledH, Image.SCALE_SMOOTH);
JFrame gsBframe = new JFrame("resized greenscale image");
gsBframe.setDefaultCloseOperation(gsBframe.DISPOSE_ON_CLOSE);
Icon gsBicon = new ImageIcon(gsBnewimage);
JLabel gsBLabel = new JLabel(gsBicon);
gsBframe.getContentPane().add(gsBLabel, BorderLayout.CENTER);
gsBframe.setSize(705, 553); //set new window's size
gsBframe.setLocation(0,100); //set new window's location
gsBframe.setVisible(true);
====================================================
thanks heaps
cooper

by the way, i have increased the jvm's heap size:
netbeans_default_options="-J-Xms256m -J-Xmx512m -J-XX:PermSize=256m -J-XX:MaxPermSize=256m -J-Xverify:none"

Similar Messages

  • Hi I'm Barb I have another question - thanks to Eric Root was able to install OSX - but had problum when it wanted to set everything up beCause I forget my login info so I put it thru as No Sign In - I got my info and would like to have OS X set itself up

    Hi I'm Barb I have another question - thanks to Eric Root was able to install OSX - but had problem when it wanted to set everything up because I forget my login info so I put it thru as No Sign In - now I have my info and would like to have OS X set itself up can I get back to that setup point? and of course how? Thanks again Eric

    Hi Eric -As to both questions I must tell you how relieved you made me, I've been on mac's since 1990? and this is truthfully the first time I've received a intelligent understandable response without have to go through 3 or 4 people - You are really Great - hope you won't mind my coming back to you if I need to. Thanks Again   -   Oh by the way I did what you said and did it manually easier and safer. Barb

  • HT201413 I for got my security question thank you

    I for got my security question thank you
    <Email Edited by Host>

    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.
    This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • Analytics Review Questions- Thanks!

    Application info- is this tracking the total amount of downloads of the actual application via itunes, or folio downloads? If folio downloads, what is the difference between the applicatoin info. and folio info.?
    - First time launch is just that, first time launch of_____?
    - Launches is total launches for ____?
    Are hyperlinks, videos, etc. tracked uniquely or duplicates based on total amount of foilo and/or applicaiton metrics?
    If a folio is no longer published, but a consumer has this still on their phone- are you tracking their actions, views still in metrics, or does it stop?
    Is there an 800 for help on these topics?
    Thanks!

    Hi Jenny,
    Here are the responses:
    1) iTunes can track app downloads. Once the app is downloaded, installed and launched for the first time, that is when DPS can track app first launch and startups. If readers download the app and never launch it, then you will find discrepancies between app download number from App Store and app first time launch number from DPS
    2) after the consumer downloads the app from App Store, and launches it for the first time then this triggers DPS's "app first time launch" event.
    3) this question is not clear. But here is some more info that could help. For folios that are not available for download, but if the folio has been previously downloaded - then as long as readers are reading the folio all folio related events will be tracked in DPS.
    Shikha

  • NForce Chipset Driver Question: Thanks :)

    I looked around the forums but did not find a answer so I hope someone will be able to help.
    I will be reinstalling my system in a few days to windows x64 and had a question about nForce Drivers. My mobo is the MSI Neo4 Plat. Can I use nForce 4 x16 drivers or do I need to use the regular set?
    Thank you so much.

    Quote from: FrankenBerrie on 08-March-06, 02:25:29
    Is there a post showing the best bios settings for the Neo4 Plat?  Thanks
    go with auto settings. you might want to set the memory voltage manually according to the manufacturer's specs, and just make sure that the memory is working at 1T. if it defaults at 2T, you can also change that from BIOS. if you plan to overclock, there are guides on the BIOS settings in the overclocking sections of the forum. if you have any problems, just drop a post here or in the overclocking section.

  • Please someone help asap with exchange/return question thank you

    purchased a tv last night friday april 30th,2010. I opened it and put where i needed to, it is too small. Do I have to pay the restocking fee if I take back today and get another Tv thats larger? Essentially I am gonna get a comparable tv thats larger, around same price if not more. Very confused dont wanna pay $300 for 15%, not sure if it applies here, thank you. Box is perfect condition all things put back nicely.

    Relax. Assuming all parts are accounted for, and the TV is in new condition(and you have the receipt), there will be no problem exchanging it.
    Disclosure: Former BBY employee.

  • HT5569 Hi is it possible to install and setup a modem with an iPad only, I would appreciate  an answer to this question thanks

    Hi is it possible to install and setup a modem with an iPad only, I would appreciate  an answer to this question thanks

    The configuration page of my router on Safari (tap to enlarge)
    See IP Adress at the top (center)

  • Please clarify my question, Thanks!

    (1)From the form I use the following code to call a report,
    SET_REPORT_OBJECT_PROPERTY(V_REPORT_ID,REPORT_DESTYPE,FILE);
    SET_REPORT_OBJECT_PROPERTY(V_REPORT_ID, REPORT_DESFORMAT,'wide'); "
    setting in the 'wide' file as followings:
    printer "wide"
    height 66
    width 132
    after page control(L)
    return control(M)
    linefeed control(J)
    (2) in my report, I set Main section property in Layout Model, there are also ' Width' , 'Height', 'Report Width' and 'Report Height' settings.
    (3)I 'm confusing about these width, height setting, Can anybody tell me what differenc among them. How are they used during the printing.
    Thank You!

    1) Your "wide" prt file will be used when the report is a "character mode" report while printing .
    2) Please read more about character mode reports in building reports manual
    http://otn.oracle.com/documentation/reports_dev.html (links to all docs)
    http://download.oracle.com/docs/html/B10310_01/toc.htm ( building reports - html)
    http://download.oracle.com/docs/pdf/B10310_01.pdf (building reports -pdf 8 MB)
    Thanks
    The Oracle Reports Team

  • HT201303 Please, I want to reset the security questions     Thanks

    Please, I want to reset the security questions
    Thanks

    If you have a rescue email address set up on your account then you can try going tohttps://appleid.apple.com/ and click 'Manage your Apple ID' on the right-hand side of that page and log into your account. Then click on 'Password and Security' on the left-hand side of that page and on the right-hand side you might see an option to send security question reset info to your rescue email address.
    If you don't have a rescue email address then go to Express Lane  and select 'iTunes' from the list of 'products' in the middle of the screen.
    Then select 'iTunes Store', and on the next screen select 'Account Management'
    Next choose 'iTunes Store Account Security' and fill in that you'd like your security questions/answers reset.
    You should get an email reply within, I think, about 24 to 48 hours (and check your Spam folder as well as your Inbox).

  • HT5312 I have already apple ID and pass word but I did not provide a rescue email . How can I set a rescue email?  NOTE: I forgot my security question.thanks

    provide a rescue email . How can I set a rescue email?  NOTE: I forgot my security question.thanks

    You won't be able to add a rescue email address until you can answer 2 of your questions, you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down the HT5312 page that you posted from to add a rescue email address for potential future use

  • Another battery question thank you so much if you could help...

    Sorry i didn't ask this in my other thread but i wouldn't get any replies if i did that lol... OK I wanna make sure Best Buy isn't giving me the old macbook pro for the price of the new one... In the System Profiler under Power it shows that my computer's battery has a maximum capacity of 6650 mAh... is that the charge capacity of the new macbook pro battery?? I just got this mac like 3 or 4 days ago... so far doing basic things like word processing the battery hasn't lasted more than 3 or 4 hours with the brightness at minimum and using the lower power nvidia 9400m... thank you so much if you could help me confirm that I do have the new macbook pro model and battery so I can stop worrying about this lol

    Hi bodyboarder3452,
    Another easy way to tell is from the external, bottom enclosure. Do you have a latch door on the bottom that allows you easy access to the HD and a removal battery? If not then you have the model with the "built in" 7-hour battery. The FCC definitely would seem to indicate that you have the 7-hour battery, as the typical FCC of the previous generations was more in the ~5500mAh range.

  • HT201363 Hi I have forgotten my id questions and the recovery email will not send despite my several attempts and checks. I am now currently locked from my Apple ID account could someone help me reset my id questions thank you

    HHow do I reset my id questions if the recovery email will not send ??????

    You need to ask Apple to reset your security questions. To do this, click here and pick a method; if that page doesn't list one for your country or you're unable to call, fill out and submit this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (113787)

  • Context.xml question , Thanks

    Hi, developers:
    I would like to connect to another server using context.xml. I did like the following link: < a href="http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html"> link to instruction</a>
    In the "JDBC Data Source" :4 Configure Tomcat's Resource Factory part said a Context.xml tshould be stored in the META-INF directory .
    My problem is:
    1) where is /META-INF so I can find the contect.xml. I using tomcat5.5 and find only at Tomcat5.5\conf\context.xml?
    2) When I restart with my context.xml below, the tomcat can start but application can NOT.
    Error msd: Http status 404 : The requested resource (/account App) is not available.
    code of context.xml is:
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="account" path="/accountApp" debug="0" reloadable="true" docBase="serverdb">
    <Resource name="jdbc/dbinstance" auth="Container" type="javax.sql.DataSource"
    factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    driverClassName="oracle.jdbc.OracleDriver"
    url="jdbc:oracle:thin:@//dburl:1522/"
    username="accuser"
    password="accpw"
    maxActive="20"
    maxIdle="10"
    maxWait="120000"
    removeAbandoned="true"
    logAbandoned="true"
    removeAbandonedTimeout="300"
    testOnBorrow="true"
    testOnReturn="true"
    validationQuery="select 1 from dual" />
    </Context>
    is some one can give me a help to solve it. Thanks in advance

    The "context" here is an artifact of the way that Tomcat works. It contains deployment information - the path to the application files, the JNDI mappings and various other bits and pieces.
    The "context" of a web application is the path to which it is deployed within the application server. An application deployed to a context called "foo" would probably be accessed by the following URL:
    http://localhost:8080/foo/And the application files would probably be stored somewhere like this:
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\fooTomcat keeps its context information EITHER in a file called server.xml or in a seperate file named after the application's context. So typically it will be in one of these files (for our "foo" application):
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost\foo.xmlYou can create the entry in one of several ways:
    1. Edit server.xml manually
    2. Edit foo.xml manually
    3. Use an application such as the admin webapp to deploy your application
    4. Include a Context.xml file in the META-INF directory of the application
    The last option allows you to specify the default values that you want the application to take up when you deploy it to Tomcat. This saves time during development, but may cause problems for your clients when they come to deploy the application themselves.
    It is this last file that you seem to be talking about. You would normally create it as a directory and file within the source directory for your application, from which you build and deploy a WAR file. For example, you might build the following files and directories into foo.war:
    C:\dev\foo\index.jsp
    C:\dev\foo\WEB-INF\web.xml
    C:\dev\foo\META-INF\MANIFEST.MF
    C:\dev\foo\META-INF\Context.xml
    This would be built to a WAR file called foo.war that represents a Zip of the contents of the C:\dev\foo directory. Deploying this will cause Tomcat to notice Context.xml and extract its contents into the conf/Catalina/localhost directory as foo.xml

  • Satus bar, please answer this question. thanks

    Which of the following is not seen by the user normally in the status bar of the
    SAP screen
    a. client number/id
    b. session number
    c. data server name/id
    d. user id/name
    e. information, error, and warming messages

    " then why have the £2.99 apps not changed prices? "
    The app developers and Apple can choose to price their product however they like.  Reasons could be market conditions, costs ( legal, taxes, structure, licensing,etc), simple profit strategy, market positioning, etc.  They could just decide that they need more profit.  All businesses have this freedom and exercise it.
    "Looks to me as if I'm getting ripped off. "
    Not any more that with any other product or service you buy.  Everyone prices their product/service as they see fit.  the consumer can then deice to purchase or not.
    "Can you guys at Apple please answer this question? "
    No.  Apple will not respond to you here at all.  This is a user forum.
    They certainly will not explain their pricing strategy to your in any case, just as most any other company does not.

  • How can I change my security questions thanks :)

    How can I change my security questions please respond thanks

    If you know their current answers, then from http://support.apple.com/kb/HT5312
    Navigate to appleid.apple.com using your web browser.
    Click "Manage your account"
    When prompted, sign in using your Apple ID and password.
    Click Password & Security
    You'll be asked to answer 2 of your 3 security questions before you can make any modifications. If you are unable to remember your answers, you can choose to send an email to your rescue email to reset your security questions.
    You should then get a screen where you can change them
    If you can't remember their answers and you have a rescue email address (which is not the same thing as an alternate email address) set up on your account then those steps should give a reset link.
    If you don't have a rescue email address (you won't be able to add one until you can answer 2 of your questions) then you won't get the reset option - you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset (and if you don't already have a rescue email address) you can then use the steps half-way down this page to add a rescue email address for potential future use : http://support.apple.com/kb/HT5312

Maybe you are looking for

  • Mac Pro won't boot, kernel panic at boot, graphics card failure.

    Yesterday my screen (30" Apple Cinema) started showing symptoms of graphics card failure, jagged lines across the screen. I rebooted my Mac Pro and it was gone. Then it happened again an hour later, this time the machine didn't boot, I get the Apple

  • Shared Variable Alias vs Programmatic Assignment, which is better?

    Hello, I am programming an application for a cRIO platform using the scan engine in LV2009SP1.  I'd like to use the cRIO as a standalone controller, and only connect a computer to it occasionally to download data.  I decided to do this using shared v

  • Placed calls and messages not showing on-line

    I'm the account administrator of 2 lines so I can see calls and messages that the other line makes except I can't figure out why some do not show up. Can anyone help me with this? Example: I was present when my family member received a call/hung up w

  • Need configure wifi, but adobe air cd won't install, why?

    Am trying to configure wifi after installing new motorola wireless modem sbg901 and am trying to run the cd wifi instrux. It asks to install Adobe Air, but it won't install. Why can't I install Adobe Air?

  • Getting started with UCM

    Can someone post link to some good Oracle UCM 11g tutorials. I am a novice and need to kickstart with content management. Thanks, Sk