@ -27,12 +27,15 @@ import java.io.IOException;
import java.io.InputStreamReader ;
import java.io.InputStreamReader ;
import java.lang.reflect.Constructor ;
import java.lang.reflect.Constructor ;
import java.lang.reflect.Method ;
import java.lang.reflect.Method ;
import java.util.ArrayList ;
import java.util.Hashtable ;
import java.util.Hashtable ;
import java.util.List ;
import java.util.Properties ;
import java.util.Properties ;
import java.util.Vector ;
import java.util.Vector ;
import de.anomic.kelondro.util.Log ;
import de.anomic.kelondro.util.Log ;
import de.anomic.kelondro.util.FileUtils ;
import de.anomic.kelondro.util.FileUtils ;
import de.anomic.tools.consoleInterface ;
public final class serverSystem {
public final class serverSystem {
@ -109,10 +112,6 @@ public final class serverSystem {
if ( isWindows ) maxPathLength = 255 ; else maxPathLength = 65535 ;
if ( isWindows ) maxPathLength = 255 ; else maxPathLength = 65535 ;
}
}
/ * public static boolean isWindows ( ) {
return systemOS = = systemWindows ;
} * /
public static Object getMacOSTS ( final String s ) {
public static Object getMacOSTS ( final String s ) {
if ( ( isMacArchitecture ) & & ( macMRJFileUtils ! = null ) ) try {
if ( ( isMacArchitecture ) & & ( macMRJFileUtils ! = null ) ) try {
if ( ( s = = null ) | | ( s . equals ( blankTypeString ) ) ) return macMRJOSNullObj ;
if ( ( s = = null ) | | ( s . equals ( blankTypeString ) ) ) return macMRJOSNullObj ;
@ -215,6 +214,38 @@ public final class serverSystem {
return getMacFSCreator ( f ) . equals ( creator ) ; // this is not always true! I guess it's caused by deprecation of the interface in 1.4er Apple Extensions
return getMacFSCreator ( f ) . equals ( creator ) ; // this is not always true! I guess it's caused by deprecation of the interface in 1.4er Apple Extensions
}
}
/ * *
* finds the maximum possible heap ( may cause high system load )
* @return heap in - Xmx < i > [ heap ] < / i > m
* @author [ DW ] , 07.02 .2009
* /
public static int getWin32MaxHeap ( ) {
int maxmem = 1000 ;
while ( checkWin32Heap ( maxmem ) ) maxmem + = 100 ;
while ( ! checkWin32Heap ( maxmem ) ) maxmem - = 10 ;
return maxmem ;
}
/ * *
* checks heap ( may cause high system load )
* @param mem heap to check in - Xmx < i > [ heap ] < / i > m
* @return true if possible
* @author [ DW ] , 07.02 .2009
* /
public static boolean checkWin32Heap ( int mem ) {
String line = "" ;
final List < String > processArgs = new ArrayList < String > ( ) ;
processArgs . add ( "java" ) ;
processArgs . add ( "-Xms4m" ) ;
processArgs . add ( "-Xmx" + Integer . toString ( mem ) + "m" ) ;
try {
line = consoleInterface . getLastLineConsoleOutput ( processArgs , new Log ( "MEMCHECK" ) ) ;
} catch ( final IOException e ) {
return false ;
}
return ( line . indexOf ( "space for object heap" ) > - 1 ) ? false : true ;
}
public static String infoString ( ) {
public static String infoString ( ) {
String s = "System=" ;
String s = "System=" ;
if ( systemOS = = systemUnknown ) s + = "unknown" ;
if ( systemOS = = systemUnknown ) s + = "unknown" ;
@ -383,6 +414,9 @@ public final class serverSystem {
if ( args [ 0 ] . equals ( "-u" ) ) {
if ( args [ 0 ] . equals ( "-u" ) ) {
openBrowser ( args [ 1 ] ) ;
openBrowser ( args [ 1 ] ) ;
}
}
if ( args [ 0 ] . equals ( "-m" ) ) {
System . out . println ( "Maximum possible memory: " + Integer . toString ( getWin32MaxHeap ( ) ) + "m" ) ;
}
}
}
}
}