gvsig-projects-pool / org.gvsig.jvmpreferences / trunk / org.gvsig.jvmpreferences.native / org.gvsig.jvmpreferences.native.lib / org.gvsig.jvmpreferences.native.lib.api / src / main / java / org / gvsig / jvmpreferences / nativeprefs / MemoryPreferences.java @ 6
History | View | Annotate | Download (2.8 KB)
1 |
package org.gvsig.jvmpreferences.nativeprefs; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
/**
|
6 |
* This class abstracts the complexity of reading/storing
|
7 |
* memory preferences for different operating systems.
|
8 |
* It has methods to
|
9 |
* read and write the configured maximum memory for gvSIG, and it provides
|
10 |
* other convenience methods related with memory management.
|
11 |
*
|
12 |
* Note that the configuration managed by this interface is system-dependent
|
13 |
* (different configuration files are used on each operating system), so
|
14 |
* different implementations are provided for each system.
|
15 |
*
|
16 |
* @author Cesar Martinez Izquierdo
|
17 |
*
|
18 |
*/
|
19 |
public interface MemoryPreferences { |
20 |
|
21 |
/**
|
22 |
* Gets the absolute path to the memory configuration file
|
23 |
*
|
24 |
* @return
|
25 |
*/
|
26 |
public File getConfigFile(); |
27 |
|
28 |
/**
|
29 |
* Checks whether the current Java process has write permission on the
|
30 |
* memory configuration file. As, gvSIG can be installed on a folder
|
31 |
* having restricted permissions, the file may not be writable unless
|
32 |
* gvSIG is executed as administrator. This is usually the case in
|
33 |
* Windows Vista, 7 and 8.
|
34 |
*
|
35 |
* @return Returns <code>true</code> if the configuration file is writable by this process,
|
36 |
* <code>false</code> otherwise.
|
37 |
*/
|
38 |
public boolean isConfigWritable(); |
39 |
|
40 |
/**
|
41 |
* Returns the total amount of RAM memory installed on this computer.
|
42 |
*
|
43 |
* @return The total amount of memory, measured in megabytes
|
44 |
*/
|
45 |
public int getTotalSystemMemory(); |
46 |
|
47 |
/**
|
48 |
* Gets the maximum amount of memory (in megabytes) that
|
49 |
* it is considered to be safe for this computer.
|
50 |
*
|
51 |
* This amount is calculated based on
|
52 |
* different parameters such as the total amount of available
|
53 |
* RAM memory on the computer and the architecture of the
|
54 |
* JVM (32 bits or 64 bits).
|
55 |
*
|
56 |
* Due to the way in which the Java Virtual Machine, it is
|
57 |
* unsafe to use more than ~1200 MB for 32 bit JVMs, as the
|
58 |
* JVM needs a contiguous memory space and it will not start
|
59 |
* at all if it is not available. Note that the availability
|
60 |
* of a free, contiguous memory space also depends on the
|
61 |
* previously loaded programs, so an unsafe value may work
|
62 |
* on one JVM execution and fail on a different one.
|
63 |
*
|
64 |
* @return
|
65 |
*/
|
66 |
public int getSafeMemoryMaximum(); |
67 |
|
68 |
/**
|
69 |
* Reads the maximum configured memory (-Xmx) from gvSIG
|
70 |
* launch configuration file
|
71 |
*
|
72 |
* @return The maximum configured memory, measured in megabytes
|
73 |
*/
|
74 |
public int readConfiguredMaximum(); |
75 |
|
76 |
/**
|
77 |
* Sets the maximum memory parameter (-Xmx) on the gvSIG
|
78 |
* launch configuration file. Caution: This method directly writes
|
79 |
* the parameter to the configuration file.
|
80 |
*
|
81 |
* @param maximumMemory The maximum memory, measured in megabytes
|
82 |
*/
|
83 |
public void saveConguredMaximum(int maximumMemory); |
84 |
|
85 |
/**
|
86 |
* Gets the factory default for maximum memory for gvSIG.
|
87 |
*
|
88 |
* @return
|
89 |
*/
|
90 |
public int getFactoryDefaultMaximum(); |
91 |
|
92 |
} |