How the memory alloaced

Hello friend i am new to java...
Please help me out..
class RaceCar
private int carNumber;
private static int count ;
public RaceCar()
count++;
carNumber = count;
public void showCarNumber()
System.out.println("Car number is " + carNumber);
public static void showCount()
System.out.println("Count is " + count);
class RaceCarDemo
public static void main(String[] args)
//block 1
RaceCar x = new RaceCar();
RaceCar y = new RaceCar();
RaceCar a = new RaceCar();
RaceCar d = new RaceCar();
RaceCar dd = new RaceCar();
RaceCar yd = new RaceCar();
     //which line is compiled first
     // Flow of execution
//block 2
x.showCarNumber();
y.showCarNumber();
          //how is the car number of is x is show 1 and y as 2 correctly.
          //does it store the values in x,y,...
//block 3
RaceCar.showCount();
d.showCount();
          //Can we call showCount with any object of the race car.
          // where the value of count is stored
x.showCarNumber();
Q Are all the Blocks 1 2 3 are compiled one after the other or all the variable of x, y ,... are compiled or after the other, i want to how exactly the program is compiles... like in c++ by pressing f7(may be f6) we can compile one after the other statement, in the same way do we have in java... so that i can check which statement compile one after the other.
// Flow of execution
//how is the showCarNumber of is x is show 1 and y as 2 correctly, where the value of x is stored.
//does it store the values in x,y,...
Thank you.
Edited by: 882702 on Aug 31, 2011 2:47 PM

First of all, you should format your code by placing it between \\ tags.
>
Q Are all the Blocks 1 2 3 are compiled one after the other or all the variable of x, y ,... are compiled or after the other, i want to how exactly the program is compiles
>
I am not sure I understand your question, but compilation order is pretty much irrelevant in Java. The compiler makes multiple runs through the code so it does not need any equivalent to the C++ forward reference.
If you are asking about the order it will run in, the code should run in the order it is given.
>
//how is the showCarNumber of is x is show 1 and y as 2 correctly, where the value of x is stored.
//does it store the values in x,y,...
>
Could you please rephrase these and explain in more detail?

Similar Messages

  • How the memory is allocated

    how the memory is allocated to the jvm when it is initially started and how we ca increase the memory of the jvm as per the requirements plz any body help ,e out iam very much new to the java programming and advanced thanks

    just i want to know about the stack memory Actually, you don't because you should not need to worry about it unless you try to use too many threads. e.g. over 2000 threads.
    and the heap how it will allocated Memory is pree allocated to about 2 MB and grows as required.
    Run the jvm with the -verbosegc option to see how memory is allocated.
    If you want more detail use a memory profiler such as jprofiler, optimiseit, or jprobe.

  • How and when does Berkeley free the memory of key and data ?

    Hi,
    even though i just have posted a question several days ago, i couldnt find an answere to these questions in the Berkeley docs or on the internet:
    Does Berkleley Db free the data that is handeled to it with the key or the data objekt ?
    When is it free?
    How is the data managed that is in the secondary databases which points directly to the primary database and do i have to copy it?
    It would be great to have some answeres, because its hard to write something with low memory use, when you dont know how the memory is treated.

    Hi,
    Does Berkleley Db free the data that is handeled to it with the key or the data objekt ?Records in the berkeley db is stored as 'Key' & 'Data' pair. The data is accessed into / from the db using the 'Key'. The data in the db is freed when it is deleted.
    When is it free?The data in the db is freed after 'delete' followed by 'checkpoint' operation.
    How is the data managed that is in the secondary databases which points directly to the primary database and do i have to copy it?The secondary database is just another regular database whose 'Key' is what you choose it to be and the 'Data' is the key in the primary database. The primary and secondary databases are connected using the DB->associate() call. More info with example on this is available here : [http://www.oracle.com/technology/documentation/berkeley-db/db/ref/am/second.html]
    Debsubhra Roy

  • How much memory for the G5 2.7?

    I am buying a refurbished G5 2.7 from Apple.
    The primary application will be Pro Tools HD2 for audio mixing.
    QUESTIONS:
    (1) How much memory will I likely need? 2GB? 4GB?
    (2) I will buy the memory from Crucial. Should I remove the original memory and use only the Crucial 1GB pairs, so they are matched?
    Powermac G5 2.7   Mac OS X (10.4.6)  

    No need to remove the original RAM.
    How much to install depends on how you'll be using ProTools. If it's only audio (no sample players), 2GB would probably work perfectly. If you're using samplers heavily, with lots of large samples, you might want to go to 5-6GB.
    I'd start with 4GB, RAM for these is cheap (compared to RAM for the Mac Pro.)

  • How do you prevent the organizer from mixing the order of pictures when down loading off the memory card?

    @How do you prevent the organizer from mixing the order of pictures when down loading off the memory card?

    This sounds like you are using Photoshop Elements, and the Photoshop Elements forum would be best at answering that.
    Photoshop Elements
    Gene

  • How can i get acsess to my data if my iphone is shut and can´t open any more??how can i get acsess to the memory card, how can i get acsess to my data if my iphone is shut and can´t open any more??how can i get acsess to the memory card

    how can i get acsess to my data if my iphone is shut and can´t open any more??how can i get acsess to the memory card????please help

    You can't. There is no memory card. It uses flash memory that's soldered to the logic board. If you didn't back it up, your data is gone.

  • Does anyone know how to display (in LabVIEW) the memory use during execution of an image and data acquisition VI to predict when it is time to cease the acquisition to prevent the program crashing?

    Does anyone know how to display (in LabVIEW) the memory use during execution of an image and data acquisition VI to predict when it is time to cease the acquisition to prevent the program crashing?
    I am acquiring images and data to a buffer on the edge of the while loop, and am finding that the crashing of the program is unpredictable, but almost always due to a memory saturation when the buffers gets too big.
    I have attached the VI.
    Thanks for the help
    Attachments:
    new_control_and_acquisition_program.vi ‏946 KB

    Take a look at this document that discusses how to monitor IMAQ memory usage:
    http://digital.ni.com/public.nsf/websearch/8C6E405861C60DE786256DB400755957
    Hope this helps -
    Julie

  • How to overcome the Memory leakage issue in crystal report 2008 SP2 setup.

    I have developed the small windows based application tool with help of  Visual studio 2008 for identify the memory consumption of crystal report object. It helps to load the crystal report objects in the memory and then released the object from the memory. The tool simply does the u201CLoading and Unloadingu201D the objects in the memory.
    The tool will be started once u201CTest_MemoryConsumption.Exeu201D executed. The u201CTest_MemoryConsumption.Exeu201D consumes u201C9768 KBu201D memory before load the crystal report object in memory. It means, 9768 KB is normal memory consumption for run the tool.
    Crystal report object initiated by the tool and object help to load the report in memory once the tool initiated the crystal report object. Now u201CTest_MemoryConsumption.Exeu201D consumes u201C34980 KBu201D memory during the crystal report object creation and report load process. The actual memory consumption of crystal report object is 34980u20139768=u201C25212u201DKBu201D. 
    The memory consumption u201C34980 KBu201D will be continued till the end of the process. The memory consumption will be reduced to u201C34652 KBu201D from u201C34980 KBu201D once report load process completed. It means, u201C328 KBu201D memory only released from the memory consumption. Tool enables the Release command for the crystal report object. But crystal report object does not respond to the command and will not release his memory consumption.
    The memory consumption u201C34652 KBu201D will be stayed in the memory once job ends.  If i again initiate the crystal report object then it crystal report object start to consume the memory from 34652 KB.
    Database objects and crystal report objects are properly used in the tool. The object release commands properly  communicated to crystal report setup. But the u201CCrystal report service pack 2u201D setup unable to respond the commands which has enabled from .Net Tool.  Crystal report objects are properly initiated and disposed in the tool. But the crystal report unable to release from the server.
    The memory consumption will be reduced once the server restarted or kill the application.
    Crystal report 2008 and crystal report 2008 SP2 setup available in the server.
    Microsoft .Net Framework 2.0 SP2, Microsoft .Net Framework 3.0 SP2 and Microsoft .Net Framework 3.5 SP1 are available in the server,
    Could you please suggesst how to avoid the memory consumption keep increasing and  how to release the memory consumption  once the crystal object disposed???

    Hi Don..
    My case is different one. I hope, the problem with Run time Installation setup file (Crystal report 2008 Serivce Pack2 installer) which we installed in the server.
    Let me explain with Live scenario which our client faced in crystal report 2008 Service pack2 Installer.
    Our client is using a application to help to print their reports. The application is developed with Windows service.
    Windows service keep on running in the server. Windows service executes the client 's crystal reports( Labels Report, Stock  report) which designed for clients need and the reports will be printed from printer. 
    10 Same type report (Label Report) will be printed in 1 minute. Reports are not printing during non business hours. But the windows service keep on running.  Memory cosumption of application will be 160 MB in business hours.
    For Example, On Monday the application memory consumption starts with 160 MB. The Memory consumption will be reached 165 MB  in peak business hours. Then the memory will be ended in163 MB in the End of Monday. It means, The memory consumption will be in 163 MB during the non business hours. Reports will not be printed in non business hours.
    On Tuesday, the application memory consumption starts with 163 MB and it will be reached 168 MB during the peak hours. The Memory consumption will be ended in 165 MB in the end of Tuesday.  The same process contiues till friday. End of friday, the memory consumption of the application will be ended with 170 MB.
    Application Memory Consumption slowly increasing in the server. In 5 days, Memory consumption reached Threshold value (170 MB) of the server. Application gets hanged up once the memory consumption reached 170 MB. We got the error messages as "Attempted to read write protected memory " / "Not Enough memory for process".  If we restart server / If we restart the service then memory consumption of application get reduced to 160 MB.
    From the above scenario, We came know that the either the problem with Application object or the problem crystal report object. In the application, We have checked dispose methods of application objects completly. I am sure that  application objects are properly disposed in the application. I hope the problem not with application objects. The problem with Crystal report objects.
    Application properly communicates the dispose methods to crystal report objects. Crystal report objects are not released from
    the memory.
    Crystal report 2008 Serive Pack 2 setup installed in the server. 
    As you said, If Crystal report runtime is not released from memory then memory consumption keep increase???  In service oriented architecture application, how to unload the crystal report runtime??
    Do you any fix for this kind of issue??
    Willl Crystal report 2008 service pack 3 help on this issue??

  • How do you "pause" an open application, like Mac automatically does when the memory is full?

    How do you "pause" an open application, like Mac automatically does when the memory is full?
    I would like to do so proactively when I am not using a certain program but need to keep it open, and I want to free up computer resources.
    In other words, I want to keep a given program open, but stop it from "thinking".

    There is an application that I can only open a set number of times before it expires.  Every time the program closes, you get one less use out of it.  I want to use it as long as possible, so I thought I would just keep it open all the time.  However, it consistently turns on the fan on the computer, so I imagine it uses a lot of resources.  I got the idea after the Force Quit program "paused" it once after getting overloaded with all the apps I had open.  It stopped the fan, and I was able to open it and run it again later with no problems.  The tricky thing with trying to intentionally overload the system is that it's a hit or miss on which open program the OS will pause (to my knowledge).

  • How do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full

    how do you remove back up data from the memory storage? my storage data states that i have over 80gb of data used for back ups and i dont know why as i use a external hard drive as a time machine .now my 250gb flash storage is nearly full.. HELP!

    When Time Machine backs up a portable Mac, some of the free space will be used to make local snapshots, which are backup copies of recently deleted files. The space occupied by local snapshots is reported as available by the Finder, and should be considered as such. In the Storage display of System Information, local snapshots are shown as  Backups. The snapshots are automatically deleted when they expire or when free space falls below a certain level. You ordinarily don't need to, and should not, delete local snapshots yourself. If you followed bad advice to disable local snapshots by running a shell command, you may have ended up with a lot of data in the Other category. Ask for instructions in that case.
    See this support article for some simple ways to free up storage space.

  • How to delete the memory in "other"?

    how do i delete the memory in "other" in my iphone4 . i accidentally restored the data in other as well prior.So restore didnt work.please help. i have come across many questions relating and referred communtities . but no satisfactory answers ..

    You cannot delete it all.  It is normal to have a gb or so in other.
    Much more than this indicates corrupt files.  A restore is how you get rid of it.  If restore from backup does notwork, then restore as new.

  • How to increase the memory for my weblogic server in Jdeveloper 12.1.2.0.0 ?

    Hey everyone,
    So as my title says, i'm trying to increase the memory for my weblogic server in my windows 7 64 bit machine, with 8GB ram.
    The values appear to be: JAVA Memory arguments: -Xms256m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m
    I've done some search from this forum and i've added this to my jdev.conf:
    AddVMOption  -XX:MaxPermSize=1536M (in this one i've only changed the value)
    AddVMOption -Xmx1536M
    AddVMOption -Xms1536M
    And i've changed this: MEM_ARGS="-Xms1024m -Xmx1024m" in my startNodeManager.sh file
    I'm still getting the same line in my server but i need to change the values since i'm not getting the server to run my application very well (it gets stucked in loading my databases and graphs) and i think it will continue untill i get a heap exception error.
    Any ideas of how to change this?
    Regards,
    Frederico.

    Thanks Alejandro .
    I'm going to ask you another question and this one is quite important.
    Whenever i run my project a couple of times, i'm not able to retrieve the page, it just gets stuck on loading.
    It just stops the loading, like its a really really slow page. I'm not using a lot of rows in my database so i don't take to much memory but it doesn't load and i know everything is fine but i just added some graphs after testing it.
    Do you know why?
    In the console it says that everything is fine and shows the link for the page but it never loads completely until it gives a error because it does not respond in 600 seconds.
    Strange right?

  • HT2731 I have 2 apple iPods on the same account, And they have the Same songs on them. How can I get a new account for one of them but not the other? Can I wipe the memory of 1? How would I do that?

    I have 2 iPods one I don't use anymore. I would like to make a new account for one but not the other. Is that possible? If I wipe the memory in one will the other wipe out too? How can I do all of this?

    You don't have to do anything with the first iPod that you don't use anymore. If you are planning on keeping it, put in a drawer in your house and forget about it.
    You don't need a second account to use with the new iPod. I use one Appl e ID and iTunes library for two iPods, and two iPad. I have different content on all four devices. You can select exactly what you want to sync to each device and it can be different content on all devices.

  • How to create a temp table in the memory, not in disk?

    in sql server, you can create a temp table in the memory instead of disk,
    then you can do the insert, delete,update and select on it.
    after finishing, just release it.
    in Oracle,
    I am wonderfing how to create a temp table in the memory, not in disk?
    thanks,

    Thanks for rectifying me Howard.
    I just read your full article on this too and its very well explained here:
    http://www.dizwell.com/prod/node/357
    Few lines from your article
    It is true, of course, that since Version 8.0 Oracle has provided the ability to create a Keep Pool in the Buffer Cache, which certainly sounds like it can do the job... especially since that word 'keep' is used again. But a keep pool is merely a segregated part of the buffer cache, into which you direct blocks from particular tables (by creating them, or altering them, with the BUFFER POOL KEEP clause). So you can tuck the blocks from such tables out of the way, into their own part of the buffer cache... but that is not the same thing as guaranteeing they'll stay there. If you over-populate the Keep Pool, then its LRU mechanism will kick in and age its contents out just as efficiently as an unsegregated buffer cache would.
    Functionally, therefore, there can be no guarantees. The best you can do is create a sufficiently large Keep Pool, and then choose the tables that will use it with care such that they don’t swamp themselves, and start causing each other to age out back to disk.
    Thanks and Regards

  • How to check the Memory consumtions and time taken by a Java Program??

    HI all,
    I want to know how to check for the Memory Usage of an XML Parser.
    See, a product was developed completely in DOM parser and now I am replacing that thing with SAX Parser Completely, because the DOM parser was taking huge memory as u may have guessed.
    BUt the thig is that, now I want to check how much memory is being taken by the SAX parser alone and DOM parser alone so that I can compare them.
    Can anyone suggest me how to do that ???
    Thanx in Advance
    Kaushik

    Thanx boss ..thanx a lot
    I tried that, but in the API docs, it is mentioned that freeMemory()Returns the amount of free memory "in the system"
    and totalMemory() Returns the total amount of memory in the "Java Virtual Machine".
    So if I compare both the Values then would it give the Correct result to me ???? Beacuse the freeMemory() gives the data in terms of the Host System whereas totalMemory() provides the data in terms of Java Virtual Machine ..... are they Same ?????
    I think I am clear in explaining what exactly is going on my mind ...
    Please clarify
    Thanx again
    Kaushik

Maybe you are looking for

  • How to convert .doc file into .rtf file in Java?

    Hello All, I want to convert doc file into rtf format in java and for the same i am not getting any help so pls suggest some solution for that. Thanks and Regards only1Vinay

  • How to display the master TOC when using Context help in a merged document

    I use Robohelp 10. I have created a large Merged Webhelp project and I have set out the project master with nothing in it other than merged projects place markers. This is the layout of the generated projects etc. Generate           Master.htm       

  • Interactive pdf form in InDesign repeat text field

    I am working to create an interactive pdf form. The name field needs to be displayed several times. I would to create form in such a way that once the user enter the name once, the same name is used in all other places. Please help.

  • Web dynpro UI element visibility

    Hi My situation is this. I have a view on which I want to display certain fields to the user depending on whether a particular value is present in a database table. In the Context I have attributes of type WDUI_VISIBILITY which are mapped to the rele

  • No audio during calls

    iphone 4 just replaced because it would not charge and now i have no audio during calls all other sound works fine was doing the same on ios 5(what the phone came with)