Where is String object in memory? and why?

I read an article about String, it states:
String str1 = new String("abc");
the String object in the heap,
String str2 = "abc";
then String object will be in data segment?
is the statement true? and why? it's a really interesting question, thx

Thanks you so much for the great article!!
cotton.m!!
I can cheat on my assignment again, haha!
strange
Stepwise Refinement :|
http://forum.java.sun.com//thread.jspa?threadID=5206258

Similar Messages

  • What is application memory and why does my macbook pro keep running out of it?

    what is application memory and why does my macbook pro keep running out of it?

    There is excessive swapping of data between physical memory (that is, the memory chips on the logic board) and virtual memory (one or more files on the startup volume.) That activity is relatively slow and causes the whole system to be less responsive. It can happen for two reasons:
              A long-running process with a memory leak (a kind of bug)
              Not enough memory for your usage pattern
    Please note that if the cause is a memory leak, installing more memory will not help. That's likely if you already have more than 4 GB of memory. Tracking down a memory leak can be difficult, and it may come down to a process of elimination.
    These instructions are for OS X 10.9 and later. Some details may be slightly different for earlier versions of OS X.
    When you notice the swap activity, open the Activity Monitor application and select All Processes from the View menu, if it's not already selected. Select the Memory tab. Click the heading of the Real Mem column in the process table twice to sort the table with the highest value at the top. If you don't see that column, select
              View ▹ Columns ▹ Real Memory
    from the menu bar.
    If one process (excluding "kernel_task") is using much more memory than all the others, that could be an indication of a leak. A better indication would be a process that continually grabs more and more real memory over time without ever releasing it. Here is an example of how it's done.
    The processes named "Safari Web Content" render web pages for Safari. They use a lot of memory and may leak if certain Safari extensions or third-party web plugins are installed. Consider them prime suspects.
    Another process often implicated in memory leaks is "inkjet4" or "inkjet8," which is a component of the HP printing software. If it's present, force-quit the process in Activity Monitor to solve the problem temporarily. Empty the print queues in the Printers & Scanners preference pane (which has a slightly different name in each recent version of OS X.) If you don't use an HP printer, reset the printing system. Otherwise, if the problem is recurrent, update the software (which may not help) or contact HP support.
    "Wired" memory should be a small part of the total. That memory is not swapped, but it makes less physical memory available which may then result in swapping. If you have a lot of wired memory, that's usually an indication of a memory leak in a third-party program that modifies the operating system at a low level. Ask for guidance in that case.
    If you don't have an obvious memory leak, your options are to install more memory (if possible) or to run fewer programs simultaneously.
    The next suggestion is only for users familiar with the shell. For a more precise, but potentially misleading, test, run the following command:
    sudo leaks -nocontext -nostacks process | grep total
    where process is the name of a process you suspect of leaking memory. Almost every process will leak some memory; the question is how much, and especially how much the leak increases with time. I can’t be more specific. See the leaks(1) man page and the Apple developer documentation for details.

  • Hana is a Database or Memory and why BW on Hana?

    Dear Experts,
    I have read few documents regarding Hana and I am confused?
    Following is my understanding. Correct me if I am wrong in my understanding?
    1. I believe Hana is a database(a different kind of data base with Software and hardware) which stores the data and is very fast.
    This Hana Database comprises of both Drive and Ram. Hana's Drive is for storing the Data permanently and Hana's Ram is where the full data from Drive is transferred to Ram and in-memory calculation happens which is very fast.
    2. I read that we can have 2 options,a Standalone Hana which reads data from SAP ERP and BW on Hana. Why do we need to have BW on Hana, we can just have Hana itself right, because even without BW its faster?
    Please correct me if I am wrong.
    Regards
    Sam

    A) hana is a database, which combines memory and technology.
    A common hana server has at leaste 128gb ram. why? because the tables (or columns of that tables) are loaded in memory and are consumed from there. Hana uses compresion (1:11 ratio) and use columnar tables, because it speeds up the data reading from the database.
    Hana have 3 parts of storage:
    1) memory (explained above)
    2) data: the disk where data is recorded
    3) log: the disk where the last transactions are logged and it provides with recovery fails
    B) you can have diferents scenearios (I will explain some of them):
    BW on hana: it speeds up the data access due to hana technology
    suite on hana: ERP and BW on hana
    Hana has your DW database: you can use hana like a common database and benefits your organization with the speed of hana.
    hope it helps.
    this image can show you the diferents scenarios
    http://esj.com/articles/2014/07/25/~/media/ECG/VirtualizationReview/Images/2014/07/0714vrm_hana.png

  • Object allocations, memory and UINavigationController

    I'm having a problem with object allocations
    Is it possible to release/remove a view from a navigation controller stack when I click on the back button on my navigation controller? I wish to get rid of the view I just left (the one disappearing to the right of the screen). The problem is that the next time I navigate to the same view lots of new objects are allocated, and none of the old ones are released.
    In the tableView:didSelectRowAtIndexPath: method I initialize a new view controller for the view I want to push to the stack and assign it to a property. The problem is that the old view seems to continue to exist in the navigation controller stack, because it's never released according to the "object allocation" section in Instruments, thus the amount of allocated objects and memory just grows and grows as I click back and forth in my navigation controller.
    For example, if I click on a cell in the first table view (which displays a second view) and then click on the back button and then click on the first cell again, the second view and all of its objects are created again, but the previous instance of this view seems to still exist somewhere in the navigation controller stack.
    What's the best way to solve this?
    Here's some of the code in the "tableView:didSelectRowAtIndexPath:" method:
    self.categoryController = [[CategoryViewController alloc] init];
    self.categoryController.category = category;
    [self.navigationController pushViewController: self.categoryController animated:YES];
    Each time this code is executed tons of new objects are allocated, but the objects allocated by the previous CategoryViewController are not released.

    Thanks you so much for the great article!!
    cotton.m!!
    I can cheat on my assignment again, haha!
    strange
    Stepwise Refinement :|
    http://forum.java.sun.com//thread.jspa?threadID=5206258

  • Workflow starts then cancel, where can I see the error and why it's canceled?

    Hi, I have a workflow for a document library that starts when a new document is created.  i click on the workflow status at the document library list, and it shows 
    Internal Status:
    Canceled    
    and I never got the email that the workflow supposed to send.  Where can I find out more about what cause my workflow to cancel?
    Thank you.

    Hi,
     I think so for sending mails you need to configure SMTP Service. Can you check the below link.
    http://technet.microsoft.com/en-in/library/cc288949(v=office.14).aspx
    Regards,
    MS

  • Diffrence between assign a String object  by literal and through new

    Plz tell me
    What is the diffrence between
    String x = "surya";
    or
    String y = new String("Surya");

    Plz tell me
    What is the diffrence between
    String x = "surya";
    or
    String y = new String("Surya");When String x = "surya"; is compiled it is placed in the class's pool of strings. If the same string literal is found elsewhere in the class the same string litteral in the pool is reused ( this is possible since String is immutable ).
    When you use the constructor in String to create the string, a whole new String instance is created. However, this causes extra memory allocation for no apparent advantage

  • Where is ACR  5.1 installed and why isnt it coming up with Pshop CS4

    i have CS4 installed
    with D300 NEFS i believe acr 4.2 still shows up
    it is not the new ACR
    i installed the new ACR 5.1 but i dont think it is launching
    any ideas
    where is it in the library under app support adobe
    thanks

    Glenn,
    You did not install it correctly. :/
    Make sure you have the correct location, starting the path in your ROOT level Library, not your user Library; and remove any other ACR plug-in you may have in the CS4 installation.
    At the present time, you can even use the automatic updater to update the ACR version version (5.0) installed by default to ACR 5.1.

  • Z77a-g45 where does the little speaker go and why does my computer pause on c5

    so my computer boots does evrything plays games etc but when it starts these numbers in the bottom right corner go off then it stops at c5 for a second then goes to bios screen then boots to windows. is this bad?
    also where does the little speaker plug into.

    it will be fine its just a hang not an error or failure! its just struggling for a short time to get the hard drive opperating thats all and is nothing to loose any sleep over!
    Hang = nothing to worry about really
    failure = thats the oposite of a hang its where it never starts and is to actually worry about!
    unless your computer never gets past that code and refused to load because its failed its not a issue to really bother about! like Xmad said you could try a BIO's update to the most recent one and do a firmware update if you have an SSD! its just a detection hang and an update of both could fix it!
    if you are thinking about doing a bios update use this >>Use the MSI HQ Forum USB flasher<<
    do not use live update to do the bio's flash as it has a 50/50 chance of bricking the board and the tool above has never had a failure of a flash!

  • Where did the time display go and why is the screen stuck on master track? Thanks.

    My time display disappeared and the screen is stuck on master track. Any ideas? Thanks.

    If the GarageBand application window appears to be messed up, parts missing, or in the wrong place, it might be a problem of corrupted preferences files. Try to repair permissions and to remove the file "Your Home Folder/Library/Preferences/com.apple.garageband.plist" from your user library.
    See HangTime's fix for "oddball problems":
    http://www.bulletsandbones.com/GB/GBFAQ.html#oddballprobs
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    Is your profile signature "GarageBand '09, Mac OS X (10.5.8)" still current, John? If not, and you are now using Lion or Mt. Lion, the User Library will be hidden.
    Then you can reveal it from the Finder's "Go" menu:
    Finder > Go,   then hold down the options ⌥ key, until the Library appears in the drop-down menu, select it and open the Library folder. Then go to the "Preferences" sub folder and remove com.apple.garageband.plist.
    Regards
    Léonie

  • String object vs String literal

    Hi ,
    I understand how the string objects are created using new operator and using literal.I also understand how they are stored in memory.All I want to know is that when and why should I create a String object using new and when I should create an object using literal.Is there any specific reason for creating an object using new operator when objects created by both the ways are immutable.
    Thanks for the help in advance.
    Thanks
    Mouli

    If you look at the String source code (particularly the constructors) youll learn a lot.
    String objects contain a char[] array - and this is the most important part --> a start and length value.
    I believe they were attempting to optimize, but this has important implications for developers.
    String objects dont necessarily store just the text you see, it may just reference a much bigger char array.
    For example, say an API passes you a string that is (lets pretend) a file path (C:\files\java\...\file.txt) that is 1,000,000 characters long.
    Now say that you call getFileName() and want to save the filename in a list.
    String filename = API.getFile("...").getFileName();
    List.add(filename);
    Say you do this about 250,000 times.
    You estimate that the average file name is 10 chars and ensure there is that much RAM.
    You run out of memory. Why?
    Well, this example actually happened to me in a real program I was writing to archive drive files.
    File.getFilename() returns a substring() of the entire File path.
    However, substring is implemented to return a String that just references the original char[] array!
    So the really long file path never gets garbage collected!
    I was able to fix the program by coding it:
    String filename = new String(API.getFile("...").getFileName()); // Copies only the needed chars!
    List.add(filename);
    So thats really all you need to watch out for. If memory is a concern in your program you want to
    make sure you arent referencing large char[] arrays unnecessarily.
    But like all things, this is rarely anything to give much thought to.
    Only something to remember if you run into problems after coding sensibly and profiling
    (or in my case, crashing with OOM exceptions, lol).

  • How to export & import interface type data object to memory

    Hi experts,
    My greetings to all.
    we have came across a situation where we need to pass interface type data object to memory
    and import same from memory.
    DATA context TYPE REF TO if_timecontext.
    its not possible with regular export statement.
    is their any other way to do it?
    Thanks in advanced,
    Sudhir

    Thank you saurabhmani & sandra.
    @ saurabhmani : i tried assigning object context to memory (field-symbol) and exporting it to memory, but got runtime error.
    @sandra : XML serialization & shared object concept sounds intresting but as you already checked that interface IF_TIMECONTEXT is missing the required IF_SERIALIZABLE_OBJECT interface.
    Istead of exporting context data object to memory we tried different approch and it worked out for our requirement
    Regards
    Sudhir

  • What's the difference between free memory and inactive memory?

    In activity monitor it mostly shows my having a lot of inactive memory and a lot less free memory even when I'm only running Safari for instance. What is this inactive memory and why is not available?

    This is a very informative article:
    http://docs.info.apple.com/article.html?artnum=107918

  • Why should I wrap String objects in a class for my HtmlDataTable?

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

    Hi,
    Let me describe a basic scenario in which my problem occurs. I have a backing bean and a JSP. The JSP gets a List<String> which is displayed inside a column in an editable HtmlDataTable. Each row in the data table has a UICommandLink that can perform an update to the value in the first column. Hence, the table only has two columns: one input field and one command link.
    My problem is this: When I try to execute HtmlDataTable#getRowData() when the command link is pressed, the updated values are not retrieved, but instead the values that have been in the input field before any changes were made. However, if I instead wrap my List objects inside a StringWrapper class (with a String property and appropriate getters and setters) such that I have a List<StringWrapper>, the problem does not occur. Why is this and is there any way to avoid it?
    I typed out some code to illustrate my scenario. Example 1 is where the table displays a list of String objects and Example 2 is where the table displays a list of StringWrapper objects.
    Example 1: [http://pastebin.com/m2ec5d122|http://pastebin.com/m2ec5d122]
    Example 2: [http://pastebin.com/d4e8c3fa3|http://pastebin.com/d4e8c3fa3]
    I'll appreciate any feedback, many thanks!

  • Which is better and why a = new String("AA") or a = "AA"

    Hi,
    Which is better and why
    String a = new String("AA") or
    String a = "AA"
    Does invoking a construtor waste memory? Please explain in detail.
    Thanks in advance
    Deepak

    > So in case "AA" not there in string pool,
    That is not correct.
    does new creates "AA" on string pool as well as heap memory?Yes. The literal "AA" points to a pooled String object. The new operator creates a new String object with the same character sequence ("AA"). You can verify this with a little code...
    String s = new String("AA");
    assert s != "AA";
    assert s.equals("AA");
    assert s.intern() == "AA";~

  • Why jvm maintains string pool only for string objects why not for other objects?

    why jvm maintains string pool only for string objects why not for other objects? why there is no pool for other objects? what is the specialty of string?

    rp0428 wrote:
    You might be aware of the fact that String is an immutable object, which means string object once created cannot be manipulated or modified. If we are going for such operation then we will be creating a new string out of that operation.
    It's a JVM design-time decision or rather better memory management. In programming it's quite a common case that we will define string with same values multiple times and having a pool to hold these data will be much efficient. Multiple references from program point/ refer to same object/ value.
    Please refer these links
    What is Java String Pool? | JournalDev
    Why String is Immutable in Java ? | Javalobby
    Sorry but you are spreading FALSE information. Also, that first article is WRONG - just as OP was wrong.
    This is NO SUCH THING as a 'string pool' in Java. There is a CONSTANT pool and that pool can include STRING CONSTANTS.
    It has NOTHING to do with immutability - it has to do with CONSTANTS.
    Just because a string is immutable does NOT mean it is a CONSTANT. And just because two strings have the exact same sequence of characters does NOT mean they use values from the constant pool.
    On the other hand class String offers the .intern() method to ensure that there is only one instance of class String for a certain sequence of characters, and the JVM calls it implicitly for literal strings and compile time string concatination results.
    Chapter 3. Lexical Structure
    In that sense the OPs question is valid, although the OP uses wrong wording.
    And the question is: what makes class Strings special so that it offers interning while other basic types don't.
    I don't know the answer.
    But in my opinion this is because of the hybrid nature of strings.
    In Java we have primitive types (int, float, double...) and Object types (Integer, Float, Double).
    The primitive types are consessons to C developers. Without primitive types you could not write simple equiations or comparisons (a = 2+3; if (a==5) ...). [autoboxing has not been there from the beginning...]
    The String class is different, almost something of both. You create String literals as you do with primitives (String a = "aString") and you can concatinate strings with the '+' operator. Nevertheless each string is an object.
    It should be common knowledge that strings should not be compared with '==' but because of the interning functionality this works surprisingly often.
    Since strings are so easy to create and each string is an object the lack ot the interning functionality would cause heavy memory consumption. Just look at your code how often you use the same string literal within your program.
    The memory problem is less important for other object types. Either because you create less equal objects of them or the benefit of pointing to the same object is less (eg. because the memory foot print of the individual objects is almost the same as the memory footpint of the references to it needed anyway).
    These are my personal thoughts.
    Hope this helps.
    bye
    TPD

Maybe you are looking for

  • External HD refuses to eject ~ no obvious apps/processes preventing it??

    One of my external hard drives simply refuses to eject/un-mount, and I've done everything I can think of to terminate any processes and/or applications that may be using the drive and preventing it from being ejected properly, but I haven't had any s

  • LMDefaultLayout and LMDefaultSkin environment variables not working?

    Like the title says, I haven't been able to have these two variables working, neither with my custom Layout and Skin or with the "Classic" or "Top Menus" layouts and "Oracle" skin like the documentation shows as an example. The objective is to have m

  • Cannot save or print from within Pages

    I can no longer save or print pages documents. Those menu items are grayed out. All I can do is open, close or start a new document, I've tried trashing the pref file to no avail. I also can only open pages documents from within the program, clicking

  • Conversion Exit for data type FLTP

    Can someone suggest me a conversion Exit for data type FLTP?

  • How to Access the view from another Component

    Hi, Seek your advice on this following requirement. 1. Would like to add the view OVWindow of Component BTCATEGORIES in an assignment block of      CRMCMP_CMG similar to the assignment block exists in the BT116H_SRVO component. 2. Please provide the