memory

Examples of forcing freeing of native memory direct ByteBuffer has allocated, using sun.misc.Unsafe?

你。 提交于 2020-01-09 12:52:53
问题 JDK provides abillity to allocate so-called direct ByteBuffers, where memory is allocate outside of Java heap. This can be beneficial since this memory is not touched by garbage collector, and as such does not contribute to GC overhead: this is a very useful for property for long-living things like caches. However, there is one critical problem with existing implementation: underlying memory is only allocated asynchronously when the owning ByteBuffer is garbage-collected; there is no way to

如何从进程内部确定CPU和内存消耗?

泪湿孤枕 提交于 2020-01-09 11:35:19
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我曾经负责从运行的应用程序内部确定以下性能参数的任务: 可用虚拟内存总量 当前使用的虚拟内存 我的进程当前使用的虚拟内存 总可用RAM 当前使用的RAM 我的进程当前使用的RAM 当前使用的CPU百分比 我的进程当前使用的CPU百分比 该代码必须在Windows和Linux上运行。 尽管这似乎是一项标准任务,但在手册(WIN32 API,GNU文档)以及Internet上找到必要的信息还是花了我几天的时间,因为关于该主题的信息太多,不完整/不正确/过时发现在那里。 为了使其他人免于遭受同样的麻烦,我认为将所有分散的信息以及通过反复试验发现的信息收集到一个地方是一个好主意。 #1楼 在Windows中,您可以通过以下代码获取cpu的使用情况: #include <windows.h> #include <stdio.h> //------------------------------------------------------------------------------------------------------------------ // Prototype(s)... //-------------------------------------------------------------

Memory randomization as application security enhancement?

假如想象 提交于 2020-01-09 10:54:03
问题 I recently came upon a Microsoft article that touted new "defensive enhancements" of Windows 7. Specifically: Address space layout randomization (ASLR) Heap randomization Stack randomization The article went on to say that "...some of these defenses are in the core operating system, and the Microsoft Visual C++ compiler offers others" but didn't explain how these strategies would actually increase security. Anyone know why memory randomization increases security, if at all? Do other platforms

Memory randomization as application security enhancement?

a 夏天 提交于 2020-01-09 10:51:25
问题 I recently came upon a Microsoft article that touted new "defensive enhancements" of Windows 7. Specifically: Address space layout randomization (ASLR) Heap randomization Stack randomization The article went on to say that "...some of these defenses are in the core operating system, and the Microsoft Visual C++ compiler offers others" but didn't explain how these strategies would actually increase security. Anyone know why memory randomization increases security, if at all? Do other platforms

Java 8 hashmap high memory usage

百般思念 提交于 2020-01-09 10:11:48
问题 I use a hashmap to store a QTable for an implementation of a reinforcement learning algorithm. My hashmap should store 15000000 entries. When I ran my algorithm I saw that the memory used by the process is over 1000000K. When I calculated the memory, I would expect it to use not more than 530000K. I tried to write an example and I got the same high memory usage: public static void main(String[] args) { HashMap map = new HashMap<>(16_000_000, 1); for(int i = 0; i < 15_000_000; i++){ map.put(i,

Java 8 hashmap high memory usage

时光毁灭记忆、已成空白 提交于 2020-01-09 10:10:08
问题 I use a hashmap to store a QTable for an implementation of a reinforcement learning algorithm. My hashmap should store 15000000 entries. When I ran my algorithm I saw that the memory used by the process is over 1000000K. When I calculated the memory, I would expect it to use not more than 530000K. I tried to write an example and I got the same high memory usage: public static void main(String[] args) { HashMap map = new HashMap<>(16_000_000, 1); for(int i = 0; i < 15_000_000; i++){ map.put(i,

浅尝Eclipse Memory Analyzer(MAT)

夙愿已清 提交于 2020-01-09 09:58:20
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 前言 在平时开发、测试过程中、甚至是生产环境中,有时会遇到OutOfMemoryError,Java堆溢出了,这表明程序有严重的问题。我们需要找造成OutOfMemoryError原因。一般有两种情况: 1、内存泄露,对象已经死了,无法通过垃圾收集器进行自动回收,通过找出泄露的代码位置和原因,才好确定解决方案; 2、内存溢出,内存中的对象都还必须存活着,这说明Java堆分配空间不足,检查堆设置大小(-Xmx与-Xms),检查代码是否存在对象生命周期太长、持有状态时间过长的情况。 以上是处理Java堆问题的思路,具体是怎么进行分析,这里介绍的是使用Eclipse Memory Analyzer tool(MAT)工具分析的过程。 生成dump文件 通过jvm参数--XX:-HeapDumpOnOutOfMemoryError可以让JVM在出现内存溢出是Dump出当前的内存转储快照; 或者,用jmap生产dump文件,win通过任务管理器查看tomcat的进程pid,linux用ps命令查看进程pid,然后用jmap命令(Java5:jmap -heap:format=b <pid>;Java6:jmap -dump:format=b,file=HeapDump.bin <pid>)。 我这里使用的是

AVAudioPlayer memory leak

青春壹個敷衍的年華 提交于 2020-01-09 07:18:32
问题 I'm stuck on some weird memory leak problem related to the AVAudioPlayer and I need help after trying everything that came to mind. Here is the short description of the problem - code appears right after. I initialize my player and start to play the sound track in an endless loop (and endless loop or one time play did not change the problem). Several seconds after the music started, I switch to another sound track, hence I create a new player, initialize it, release the old one (which is

How to free the memory after the BitmapImage is no longer needed?

半腔热情 提交于 2020-01-08 21:39:33
问题 First, I load a BitmapImage on the Image control on the Window . Second, I work with the Image control and then close the Window . I do it 2-3 times in a minute and my memory fills up very quickly because the images do not unload back when the window is closed. So how to unload BitmapImage from Image.Source control manually to free the memory? 回答1: I believe the solution you are looking for is at http://www.ridgesolutions.ie/index.php/2012/02/03/net-wpf-bitmapimage-file-locking/. In my case,

How to free the memory after the BitmapImage is no longer needed?

北城以北 提交于 2020-01-08 21:39:04
问题 First, I load a BitmapImage on the Image control on the Window . Second, I work with the Image control and then close the Window . I do it 2-3 times in a minute and my memory fills up very quickly because the images do not unload back when the window is closed. So how to unload BitmapImage from Image.Source control manually to free the memory? 回答1: I believe the solution you are looking for is at http://www.ridgesolutions.ie/index.php/2012/02/03/net-wpf-bitmapimage-file-locking/. In my case,