Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:12:06+00:00 2026-05-31T22:12:06+00:00

I want to bound JVM with a fixed memory limit. Can any one help

  • 0

I want to bound JVM with a fixed memory limit. Can any one help me how to do this ?

More specifically, I want that my code can use max 1024 mb memory space and my JVM has to initially block that much of memory.

Another thing, I have 4 GB memory but my JVM shows only 878 MB memory. Why ?

I got it using: Runtime runtime = Runtime.getRuntime() and runtime.totalMemory()/(1024*1024)

Why C has not this kind of issue ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:12:07+00:00Added an answer on May 31, 2026 at 10:12 pm

    Java won’t use more memory than it needs, if you have a hello world program, it won’t use 1 GB no matter what you set the maximum to.

    In C, memory is either used, or freed. There is not other state for memory. In Java, you have memory which has a string reference, a soft reference, a weak reference and no reference. The maximum memory you determines when to clean up memory and whether soft/weak refernces get cleaned up.

    The problem with C memory is you have to know when memory is no longer used, which can result in memory leaks and/or additional complexity which is exposed to the developer. Java doesn’t have these problems as it has managed memory.

    C programs also have the problem they can grow until you run out of memory+swap. For a well behaved program this is not a problem, but its another thing the developer needs to worry about because he doesn’t know how much memory the machine the program might be run on might have.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to bound google map in android around the UK,so the user can't
I understand that for a CPU-bound task that you typically want 1 thread per
I have a SQLDataSource that is bound to a ListView control but I want
I have a ListBox that is bound to a list of Persons. I want
This is what I want: There is a combo-box column bound to the ApplicationKey
I have a ComboBox that is bound to a DataSource. I want to dynamically
I have read that some of the JVMs out there can optimize code execution
This is what I want to accomplish: The bound collection on a DataGridd contain
I want to create a listbox that'll be bound to XPath, relative to the
What I want is to create my own function that will be bound as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.