原文地址:
什么是内存泄露
当某些对象不再被应用程序所使用,但是由于仍然被引用而导致垃圾收集器不能释放它们。
下图中就是内存泄露的情形。
图中的中间部分就是内存泄露的发生地。
为什么会内存泄露
让我们来分析一下下图中的例子,看看为什么会发生内存泄露。对象A时B的引用。A的生命周期时t1-t4,而B的生命周期时t2-t3.所以当B...
分类:
编程语言 时间:
2014-11-14 17:53:10
阅读次数:
215
原文地址:http://leihuang.net/2014/11/09/Builder-Pattern/
The builder pattern is a good choice when designing classes whose constructors or static factories would have more than a handful of parameter...
分类:
其他好文 时间:
2014-11-14 17:53:06
阅读次数:
251
原文地址:http://leihuang.net/2014/11/10/avoid-creating-unnecessary-objects/
首先我们来看下面两个语句的区别:
String s = new String("hello world!") ;
String s = "hello world!" ;
当你循环调用上面两个语句的时候,你会发现:第一条语...
分类:
其他好文 时间:
2014-11-14 17:52:55
阅读次数:
143
原文地址:http://leihuang.net/2014/11/13/Avoid-Finalizers/
Don´t use Finalizers, mainly because are unpredictable and we don´t know when will be executed, "don't try to be smarter than the JVM"
...
分类:
其他好文 时间:
2014-11-14 17:51:48
阅读次数:
328
以debug模式启动jetty,这个目的很明显,为了后台java代码的远程调试。
做法是:增加环境变量GRADLE_OPTS,值设置为:
-Xdebug -Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
这样通过gradle jettyRun命令启动jetty容器的时候,会有如下的显示结果,代表已经启用了debu...
分类:
编程语言 时间:
2014-11-14 17:51:45
阅读次数:
264
如前一篇博文所分析,我们可以使用广播的形式在快速按下两次音量下键的时候发出广播,以方便客户端进行捕捉。
具体实现方式如下:
/framework/base/policy/src/com/android/policy/impl/PhoneWindowManager.java
private long lastTime=0;
public int interce...
分类:
移动开发 时间:
2014-11-14 17:51:13
阅读次数:
296
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in each of...
分类:
其他好文 时间:
2014-11-14 17:50:06
阅读次数:
137
UVA10862 - Connect the Cable Wires(递推 + java的大数)
题目链接
题目大意:给你n座房子位于一条直线上,然后只给你一个cable service,要求每座房子都连上有线,方式可以是间接的通过这个房子的直接邻居连接(前提是它的邻居要连上有线),另外一种是直接连上cable service也是可以的。
解题思路:把后面的房子编号为1,前面的为...
分类:
编程语言 时间:
2014-11-14 17:48:41
阅读次数:
179
这里要先声明一下,针对Nginx的php安装和针对apache的php安装是有区别的,因为Nginx中的php是以fastcgi的方式结合nginx的,可以理解为nginx代理了php的fastcgi,而apache是把php作为自己的模块来调用的。
先把php 和php-fpm编译安装吧 请看http://heilinux.blog.51cto.com/6123663/157558...
分类:
Web程序 时间:
2014-11-14 17:48:33
阅读次数:
317
1.线程的五种状态:创建,就绪,运行,阻塞,终止...
分类:
编程语言 时间:
2014-11-14 17:46:12
阅读次数:
164