I hope this report is valid because I am not so familiar with how a program should use the ram and under which circumstances it should free it.
When I open a world, my ram usage goes up to about 550.000K. When I summon now entities and kill them again, it will still stay up that high.
A good way to reproduce it is first using this command
and then run:
/entitydata @e[type=ArmorStand,name=Test] {CustomName:Test}
For me it freezes (ram usage goes up to 1.310.000K) and then gives this error:
[17:36:54] [Client thread/FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_25]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_25]
at g.a(SourceFile:61) [1.8.4.jar:?]
at ave.av(SourceFile:880) [1.8.4.jar:?]
at ave.a(SourceFile:325) [1.8.4.jar:?]
at net.minecraft.client.main.Main.main(SourceFile:124) [1.8.4.jar:?]
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3664) ~[?:1.8.0_25]
at java.lang.String.<init>(String.java:201) ~[?:1.8.0_25]
at java.lang.StringBuilder.toString(StringBuilder.java:407) ~[?:1.8.0_25]
at avu.a(SourceFile:40) ~[1.8.4.jar:?]
at avt.a(SourceFile:139) ~[1.8.4.jar:?]
at avt.a(SourceFile:129) ~[1.8.4.jar:?]
at avt.a(SourceFile:125) ~[1.8.4.jar:?]
at bcy.a(SourceFile:527) ~[1.8.4.jar:?]
at fy.a(SourceFile:44) ~[1.8.4.jar:?]
at fy.a(SourceFile:9) ~[1.8.4.jar:?]
at fh$1.run(SourceFile:13) ~[1.8.4.jar:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_25]
at g.a(SourceFile:60) ~[1.8.4.jar:?]
... 3 more
But the ram usage stays that high and doesn't decrease anymore until you close Minecraft
This means Minecraft neither frees ram when closing a world nor when killing entities (or when running commands). In some way the ram usage decreases, but it doesn't go back to about 550.000K.
Attachments
Comments


Are you checking the memory usage internally, via the debug (f3) menu, or externally, via task manager (or some other program)?

Please force a crash by pressing F3 + C for 10 seconds while in-game and attach the crash report ([minecraft/crash-reports/crash-<DATE>-client.txt|http://hopper.minecraft.net/help/finding-minecraft-data-folder]
) here.

I used the task manager, Minecraft itself says only 200 of 1001MB is used
Crash report shortened
---- Minecraft Crash Report ----
// Would you like a cupcake?
Time: 26.04.15 17:26
Description: Manually triggered debug crash
java.lang.Throwable
at ave.s(SourceFile:1587)
at ave.av(SourceFile:888)
at ave.a(SourceFile:325)
at net.minecraft.client.main.Main.main(SourceFile:124)
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- Head --
Stacktrace:
at bdb.a(SourceFile:309)
-- Affected level --
Details:
Level name: MpServer
All players: 1 total; [bew['Marcono1234'/26396379, l='MpServer', x=1251,27, y=57,00, z=1277,65]]
Chunk stats: MultiplayerChunkCache: 624, 624
Level seed: 0
Level generator: ID 01 - flat, ver 0. Features enabled: false
Level generator options:
Level spawn location: 1214,00,4,00,1261,00 - World: (1214,4,1261), Chunk: (at 14,0,13 in 75,78; contains blocks 1200,0,1248 to 1215,255,1263), Region: (2,2; contains chunks 64,64 to 95,95, blocks 1024,0,1024 to 1535,255,1535)
Level time: 606638 game time, 51030 day time
Level dimension: 0
Level storage version: 0x00000 - Unknown?
Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
Forced entities: 502 total;
... (all 502 ArmorStands) ...
Retry entities: 0 total; []
Server brand: vanilla
Server type: Integrated singleplayer server
Stacktrace:
at bdb.a(SourceFile:309)
at ave.b(SourceFile:2296)
at ave.a(SourceFile:334)
at net.minecraft.client.main.Main.main(SourceFile:124)
-- System Details --
Details:
Minecraft Version: 1.8.4
Operating System: Windows 7 (amd64) version 6.1
CPU: 6x AMD Phenom(tm) II X6 1055T Processor
Java Version: 1.8.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 782111784 bytes (745 MB) / 1060372480 bytes (1011 MB) up to 1060372480 bytes (1011 MB)
JVM Flags: 6 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:-UseAdaptiveSizePolicy -Xmn128M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
Launched Version: 1.8.4
LWJGL: 2.9.4
OpenGL: AMD Radeon HD 6800 Series GL version 4.1.11161 Compatibility Profile Context, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.
Using VBOs: Yes
Is Modded: Probably not. Jar signature remains and client brand is untouched.
Type: Client (map_client.txt)
Resource Packs: []
Current Language: Deutsch (Deutschland)
Profiler Position: N/A (disabled)

JVM Flags: 6 total; ... -Xmx1G
That's the way JVM memory allocation works.
When starting the JVM, not all heap is allocated from the host, but if the heap grows mem is allocated, but never freed against the host if heap allocation shrinks.
Read on here : https://docs.oracle.com/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/garbage_collect.html
Q: How does the JVM actually allocate memory for itself?
A: For the heap it allocate one large conitnous region of memory of the maximum size. Initially this is virtual memory however, over time it becomes real memory for the portions which are used.Q: How does this relate to how the OS communicates available memory to the JVM?
A: The JVM has no idea about free memory in the OS.