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 894447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:23:20+00:00 2026-05-15T14:23:20+00:00

I have a .JAR that apparently uses up too much memory, and throws an

  • 0

I have a .JAR that apparently uses up too much memory, and throws an exception “Java heap space” (or something similar).

So I tried running the .JAR via the CMD like this:

C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m

That did not solve the problem. Same error.
Now, when I checked the Processes tab in the windows task manager, I noticed that the process of my jar has a lot less memory than what i asked for (same as running it without the parameters).

Why is it ignoring the parameters?

Also, I think the exception is thrown around the time the process reaches 100mb of memory usage. Is it possible that the GC is trying to free up the memory and that’s what causes the problem? Is there any parameter I can set for the GC to prevent that?

Thanks, Malki 🙂

  • 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-15T14:23:21+00:00Added an answer on May 15, 2026 at 2:23 pm

    The Command

    javaw -jar MyJar.jar -Xms64m -Xmx128m
    

    will use -Xms… and -Xmx… as parameters to the “main(String[] args)” method.
    Parameters to the JVM must be passed before the -jar part:

    javaw -Xms64m -Xmx128m -jar MyJar.jar
    

    The reason for that can be seen when we execute “java -version” :

    Usage: java [-options] class [args...]
               (to execute a class)
       or  java [-options] -jar jarfile [args...]
               (to execute a jar file)
    

    Where your parameters -Xms… and -Xmx… are options to the JVM.

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

Sidebar

Related Questions

I have a maven project which uses the shade plugin to create a jar
I have a jar file named xyz.jar that have the file abc.xml and I
I have an external jar that I can use in my Android application, I
I have a simple.jar file that stay in c:/JAR. When i used maven war
I have a system for which I am creating a plugin through a well
I have created an EJB3 project and a JPA project. I'm trying to create
I'm using Clover 2.5 and I've got a target that will package up the
I'm currently in the process of adding functionality to an existing J2EE webapp, in
I've been looking around for some time and couldn't find a clear explanation for
My goal is pretty simple: to use ant to build an EAR which contains

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.