Not enough memory

i run a console application from command line
i have debug output:

          Runtime rt = Runtime.getRuntime();
          System.out.println(""+i+" max:"+rt.maxMemory()+" free:"+
              rt.freeMemory()+" total:"+rt.totalMemory());

i’ve discovered playing with the last command line parameter “java poker77.v1.B2Test -J-Xmx10m” that it does not effect
help please

Try:


java -Xmx10M poker77.v1.B2Test

:wink:

Thank u, Riven
maybe somebody knows how to expand memory for NetBeans IDE?

Right click project, go properties

Click on Run

add -Xmx10M to vm options, click ok

HTH

If you really want to change this setting for IDE itself (NOT for your applications you code in it), go to the /etc and edit the netbeans.conf file.

i’ve been playing with options
the debug output is different for different options:
max:1013 free:97 total:271
and
max:506 free:96 total:271

but free memory is practically equal

any suggestions?

The free memory is inside the total memory currently available, which is 271. Both time you ran your application, it used nearly the same amount, 174-175 bytes. You are only setting the maximum memory the JVM will attempt to use, which doesn’t affect the total memory currently given to the JVM.

‘free’ is the amount of memory unused in the current heap (size = totalMemory)

if you want to get how much memory can still be allocated:


long used = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
long available = Runtime.getRuntime().maxMemory() - used;