顯示具有 Java 標籤的文章。 顯示所有文章
顯示具有 Java 標籤的文章。 顯示所有文章

2010年5月19日 星期三

JVM內存段分配,Java垃圾回收調優,Heap設定

http://hi.baidu.com/kingtckingtc/blog/item/ca5606f4decd5767ddc4740b.html

摘錄

1. java -server
2. 設置Xms=Xmx=3/4物理內存
3. 如果是CPU密集型服務器,使用–XX:+UseParallelOldGC, 否則–XX:+UseConcMarkSweepGC
4. 新生代,Parallel/ParallelOld可設大於Xmx1/4,CMS可設小,小於Xmx1/4
5. 優化程序,特別是每個用戶的session中的集合類等。我們的一個模塊中session中曾經為每個用戶使用了一個ConcurrentHashMap, 裡面通常只有幾條記錄,後來改成數組之後,每台機大概節約了1~2G內存。

2010年4月25日 星期日

Programming Android Application in Scala.

今天在 OSDC 聽到的課程,印象非常深刻,相當認同講者的觀點

2010年3月11日 星期四

ClassLoader in Java

ArrayList<URL> classPath = new ArrayList<URL>();
classPath.add(new File(workDir+"/").toURL());
classPath.add(file.toURL());
classPath.add(new File(workDir, "classes/").toURL());
File[] libs = new File(workDir, "lib").listFiles();
if (libs != null) {
    for (int i = 0; i < libs.length; i++) {
      classPath.add(libs[i].toURL());
    }
}

ClassLoader loader =
    new URLClassLoader(classPath.toArray(new URL[0]));


Thread.currentThread().setContextClassLoader(loader);
Class<?> mainClass = Class.forName(mainClassName, true, loader);
Method main = mainClass.getMethod("main", new Class[] {
    Array.newInstance(String.class, 0).getClass()
});

    String[] newArgs = Arrays.asList(args).subList(firstArg, args.length).toArray(new String[0]);
try {
    main.invoke(null, new Object[] { newArgs });
} catch (InvocationTargetException e) {
    throw e.getTargetException();
}

2009年12月2日 星期三

Barcode in Java/PHP

PHP
php-barcode (Win32, Unix-Like 都可用)
http://www.ashberg.de/php-barcode/
設定 genbarcode 的位置,若與 php code 放同目錄的話
$genbarcode_loc="genbarcode.exe";

Java
barbecue 
http://barbecue.sourceforge.net/
整包 war 放到 ap server 即可使用其 servlet
經測試,在 jboss-402 下面運作正常

以上都是從 web 生成 image,若是在 Linux Desktop 使用,據說有 kbarcode
http://www.kbarcode.net/

2009年11月24日 星期二

由 Eclipse 啟動 Tomcat 的 work 目錄

有時 jsp 會丟出這種 exception
java.lang.NullPointerException
org.apache.jsp.changepwd_jsp._jspService(changepwd_jsp.java:56)

這時就需要看一下 changepwd_jsp.java,可以用 file search 的工具去找
或是查看 work 目錄,預設為 \Tomcat\work
若是 tomcat 由 eclipse 啟動,work 目錄則為

\Workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\work\

2009年11月20日 星期五

Speed Up for Ant / 加速 Ant 編譯

make -j 可以有效利用多核 CPU 來平行編譯程式碼

>man make
-j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously.  If there is more than one -j option, the last one is effective.  If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.

ant 之於 java,就如同 make 之於 c/c++

ant 應該也有類似的作法 ?
可以使用 
http://ant.apache.org/manual/CoreTasks/parallel.html
不過,跟 make -j 一樣要小心使用,以免非預期的事情發生...

2009年11月19日 星期四

Android Native Code 的繪圖方法

先記錄一下,也許之後用得到~

文章出處
http://heaven.branda.to/~thinker/GinGin_CGI.py/show_id_doc/404