Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: JAVA Memory usage

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA Memory usage

    How do we create 1000 object in OO PROGRAMMING WITH java. What will be the memory size required?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default re: JAVA Memory usage

    How do we create 1000 object
    One way would be to use a loop.

    What will be the memory size required?
    Depends on the size of an object.

    Also posted here: https://www.dreamincode.net/forums/t...memory-needed/

    and here: https://stackoverflow.com/questions/...bjects-in-java

    and here: https://coderanch.com/t/703201/java/...va-efficiently
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA Memory usage

    How do we create 1000 objects in java efficiently and what will be the memory overhead in creating these many objects?

  4. #4
    Junior Member
    Join Date
    Dec 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA Memory usage

    Quote Originally Posted by Norm View Post
    One way would be to use a loop.


    Depends on the size of an object.

    Also posted here: https://www.dreamincode.net/forums/t...memory-needed/
    And how do we get the size of the object?

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: JAVA Memory usage

    You can't do it directly. Java has several methods that give approximations of memory usage that could be used. See the API doc for the Runtime class.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Dec 2018
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JAVA

    if the size of one object is 110 bytes and there are 1000 such objects then how can we efficiently call a method using this object so that minimum memory is required?

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: JAVA Memory usage

    It's not important to worry about that.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java.exe memory usage in Windows
    By raringsunny in forum Computer Support
    Replies: 3
    Last Post: July 27th, 2014, 06:04 AM
  2. Java.exe memory usage in Windows
    By raringsunny in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 27th, 2014, 03:26 AM
  3. Replies: 0
    Last Post: April 3rd, 2013, 09:17 PM
  4. [SOLVED] Memory usage increasing in while loop - is it a memory leak
    By mds1256 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 18th, 2012, 10:06 AM
  5. Insertion Sort - memory usage
    By lovon in forum Algorithms & Recursion
    Replies: 2
    Last Post: November 6th, 2011, 04:00 PM

Tags for this Thread