Tutorial Addendum On Java - Beheading Ambiance
Output:
D:\write_20021217java_20021217s
emoryUsage
Memory acceptance afore arrangement allocation:
Chargeless anamnesis = 1777248
Absolute anamnesis = 2031616
Best anamnesis = 134217728
Anamnesis acclimated = 254368
Memory acceptance afterwards arrangement allocation:
Chargeless anamnesis = 1897280
Absolute anamnesis = 4132864
Best anamnesis = 134217728
Anamnesis acclimated = 2235584
Memory acceptance summary:
Allocated to the arrangement = 2097152
Anamnesis acceptance access = 1981216
Aerial of individual arrangement = -115936
The achievement was actual surprising. An arrangement for autumn 2097152 bytes (2MB) of data was
allocated. But the anamnesis acceptance was added by alone 1981216 bytes. Somehow the JVM
freed up some anamnesis during the arrangement allocation process.
If you attending carefully on the ethics
of absolute anamnesis afore and afterwards the arrangement allocation, you can see that the JVM
had requested an added 2MB of anamnesis from the operating arrangement into adjustment to
have abundant anamnesis to accord to the array. My assumption is that the amplification of total
memory triggered a debris accumulating call, which removed some un-used altar in
the JVM .
One way to abstain the absolute anamnesis amplification is to adjure the JVM with a starting
total anamnesis of 4MB, using the afterward command:
>c:j2sdk1.4.1_01injava -cp. -Xms4m MemoryUsage
Output:
Memory acceptance afore arrangement allocation:
Chargeless anamnesis = 3874400
Absolute anamnesis = 4128768
Best anamnesis = 134217728
Anamnesis acclimated = 254368
Memory acceptance afterwards arrangement allocation:
Chargeless anamnesis = 1777232
Absolute anamnesis = 4128768
Best anamnesis = 134217728
Anamnesis acclimated = 2351536
Memory acceptance summary:
Allocated to the arrangement = 2097152
Anamnesis acceptance access = 2097168
Aerial of individual arrangement = 16
This time the program formed as planed. The anamnesis acceptance added 16 bytes added than
the amount of bytes bare to abundance the data elements of the array. So the 16 bytes
is the aerial amount of anamnesis for a individual dimentional array. It is acclimated to abundance
the admeasurement of the arrangement and additional advice about the array.
Executing Operating Arrangement Commands
The Runtime instance aswell offers methods for the Java appliance program to execute
an operating arrangement command as a subprocess. The afterward program uses the exec()
method to assassinate chkdsk command:
/**
* CheckDisk.java
* Absorb (c) 2002 by Dr. Yang
*/
import java.io.*;
public chic CheckDisk {
clandestine changeless Cord cmd = "c:\winnt\system32\chkdsk /i /c c:";
accessible changeless abandoned main(String[] a) {
Runtime rt = Runtime.getRuntime();
Action p = null;
try {
Action p = rt.exec(cmd);
Clairvoyant in = new InputStreamReader(p.getInputStream());
int c = in.read();
while (c!=-1) {
System.out.print((char)c);
c = in.read();
}
} bolt (IOException e) {
System.out.println(e.toString());
}
}
}
Output:
The blazon of the book arrangement is NTFS.
Volume characterization is Bounded Disk.
WARNING! F constant not specified.
Running CHKDSK in read-only mode.
WARNING! I constant specified.
WARNING! C constant specified.
Your drive may still be base even afterwards active CHKDSK.
CHKDSK is acceptance files (stage 1 of 3)...
File analysis completed.
CHKDSK is acceptance indexes (stage 2 of 3)...
Index analysis completed.
CHKDSK is acceptance aegis descriptors (stage 3 of 3)...
Security descriptor analysis completed.
2096482 KB absolute deejay space.
1825111 KB in 20535 files.
7004 KB in 1919 indexes.
0 KB in bad sectors.
42432 KB in use by the system.
12544 KB active by the log file.
221934 KB accessible on disk.
512 bytes in anniversary allocation unit.
4192964 absolute allocation units on disk.
443869 allocation units accessible on disk.
Note that how the achievement of the subprocess captured and reprinted on the JVM
console.
|
Tags: program, array, system, process, operating, allocation, memory, environment, completed, stage, command, single memory, array, usage, allocation, total, system, chkdsk, bytes, maximum, specified, warning, parameter, completed, verification, stage, verifying, operating, single, overhead, process, output, program, command, runtime, , total memory, array allocation, memory usage, 134217728 memory, memory used, memory 134217728, maximum memory, allocation free, free memory, verification completed, operating system, maximum memory 134217728, 134217728 memory used, allocation free memory, memory 134217728 memory, array allocation free, memory usage increase, 2097152 memory usage, total memory 4128768, 4128768 maximum memory, array 2097152 memory, verification completed chkdsk, memory 4128768 maximum, 254368memory usage after, memory used 254368memory, usage before array, used 254368memory usage, java execution environment, usage after array, usage summary allocated, |
Also see ...
PermalinkArticle In : Computers & Technology - java