andyzhai

posts(9) comments(2) trackbacks(0)
  • BlogJava
  • 联系
  • RSS 2.0 Feed 聚合
  • 管理

常用链接

  • 我的随笔
  • 我的评论
  • 我的参与
  • 最新评论

留言簿

  • 给我留言
  • 查看公开留言
  • 查看私人留言

随笔档案

  • 2006年3月 (1)
  • 2006年2月 (3)
  • 2005年8月 (5)

搜索

  •  

最新评论

  • 1. re: Memory Leak of Java Editors in Eclipse
  • Yes, should take snapshot after opening editor.I have to modify it
  • --Andy
  • 2. re: Memory Leak of Java Editors in Eclipse
  • Did you know Eclipse load images into ImageRegistry in lazy mode??
  • --Dennis

阅读排行榜

评论排行榜

View Post

Example of using JNI

/** Java */
public class Memory
{
    public static void main(String[] args)
    {
        System.out.println("Physical memory in system="+getPhysicalMemory()/1024+" kBytes");
    }
 
    public static native long getPhysicalMemory();
 
    static
    {
        System.loadLibrary("Memory");
    }
}
 
/** C++/JNI */
#include <windows.h> // windows standard include
#include "Psapi.h"   // windows performance API
#include "memory.h"  // JNI header file produced by JAVAH from Memory.java
 
/*
 * Class:     Memory
 * Method:    getPhysicalMemory
 * Signature: ()J
 */
JNIEXPORT jlong JNICALL Java_Memory_getPhysicalMemory(JNIEnv * env, jclass cls)
{
    PERFORMANCE_INFORMATION pi;
 
    GetPerformanceInfo(&pi,sizeof(pi));
 
    return pi.PhysicalTotal*pi.PageSize;
}
original url: http://forum.java.sun.com/thread.jspa?threadID=425258&tstart=255


useful link: http://java.sun.com/docs/books/tutorial/native1.1/

posted on 2005-08-26 03:01 Andy 阅读(497) 评论(0)  编辑  收藏

新用户注册  刷新评论列表  

只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问   管理
 
 
Powered by:
BlogJava
Copyright © Andy