SmartGC.exe provides a foundation for Java applications to more optimally control garbage collection. Since Java garbage collection is triggered by Virtual Memory (VM) usage, some applications may run more efficiently if garbage collection is triggered on available RAM or the process Working Set size.
|SmartGC Files||Size in Bytes|
The following steps describe how to use SmartGC.exe.
- Build the ATL project. This creates and registers the JVMmem ATL DLL server.
- Open the Java project, select Add COM Wrapper from the Project menu.
- Select JVMmemMod 1.0 Type Library from the list of installed COM Components.
- Build the sample.
- Click the Create button a few times until the Current Available Physical Memory is at least 5 MB lower than the initial Available Physical Memory.
- Click Delete All. This will initialize the JVMmem server to monitor Available Physical Memory.
NOTE: All of the memory statements in this article assume other applications are not consuming more memory while you run the sample test. Obviously, if you start several large applications, the current available memory will be lowered regardless of GC activity on the test sample.
The current Available memory and current working set may take some time to return to initial levels, as Windows NT does not immediately trim the working set if there is no need for RAM.
Notice the program calls SetProcessWorkingSetSize in the constructor to encourage Windows NT to limit the maximum Working Set.
Use the following steps to test that the GC sink routine is actually forcing the freeing of memory and objects:
- Click the Stop Timer button. Notice it now changes to "Start Timer."
- Create and delete several objects so the Object count is 30 but the Vector Count is zero. The memory and objects will not be garbage collected.
- After waiting until your convinced that no garbage collection will take place, click Start Timer button. Within about a minute you should see the Object Count return to zero and corresponding memory freed.
ID članka: 231294 - posljednja izmjena: 14. velj 2017. - verzija: 1