J~杰's Blog

人生就一条路,走一步有一步的景观

0%

背景

java.lang.OutOfMemoryError共有8种类型,其中java.lang.OutOfMemoryError: unable to create new native thread是很常见的一种,这类错误通常发生在应用试图创建新线程时。最近测试环境经常出现错误如下:

Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:714)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:950)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1368)
at com.alibaba.dubbo.remoting.transport.dispatcher.all.AllChannelHandler.caught(AllChannelHandler.java:65)

可能原因

  1. 系统内存耗尽,无法为新线程分配内存
  2. 创建线程数超过了操作系统的限制

解决方案

  1. 排查应用是否创建了过多的线程

    通过jstack确定应用创建了多少线程?超量创建的线程的堆栈信息是怎样的?谁创建了这些线程?一旦明确了这些问题,便很容易解决。步骤如下:

    该进程内最耗费CPU的线程pid top -Hp pid

    将pid装换成十六进制 printf “%x\n” 21742

    最后用jstack查找线程堆栈信息 jstack 21711 | grep 54ee

Read more »

以前一直用wordpress维护博客,最近看到hexo博客的样例,觉得挺炫的,今天就准备将wordpress版本的博客迁移到hexo,然后重新梳理以前的博文。

Hexo Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

升级过程

依赖库更新

和正常 Node 项目一致,使用 npm 更新即可。

更新全局 hexo-cli

1
npm update -g hexo-cli

复制

进入博客目录

查看可升级的包:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
> npm outdated
Package Current Wanted Latest Location
hexo 3.2.2 3.9.0 3.9.0 Kinegratii-blog
hexo-deployer-git 0.2.0 0.2.0 2.0.0 Kinegratii-blog
hexo-generator-archive 0.1.4 0.1.5 1.0.0 Kinegratii-blog
hexo-generator-category 0.1.3 0.1.3 1.0.0 Kinegratii-blog
hexo-generator-feed 1.2.0 1.2.2 2.0.0 Kinegratii-blog
hexo-generator-index 0.2.0 0.2.1 1.0.0 Kinegratii-blog
hexo-generator-searchdb 1.0.3 1.0.8 1.0.8 Kinegratii-blog
hexo-generator-sitemap 1.1.2 1.2.0 1.2.0 Kinegratii-blog
hexo-generator-tag 0.2.0 0.2.0 1.0.0 Kinegratii-blog
hexo-renderer-ejs 0.2.0 0.2.0 1.0.0 Kinegratii-blog
hexo-renderer-marked 0.2.11 0.2.11 2.0.0 Kinegratii-blog
hexo-renderer-stylus 0.3.1 0.3.3 1.1.0 Kinegratii-blog
hexo-server 0.2.0 0.2.2 1.0.0 Kinegratii-blog
hexo-symbols-count-time 0.4.4 0.4.4 0.6.1 Kinegratii-blog
hexo-wordcount 2.0.1 2.0.1 6.0.1 Kinegratii-blog

复制

全局安装 npm-check工具

1
npm install -g npm-check

复制

更新所有包

1
npm-check -u --registry https://registry.npm.taobao.org

复制

升级后的版本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"dependencies": {
"hexo": "^3.9.0",
"hexo-deployer-git": "^2.0.0",
"hexo-generator-archive": "^1.0.0",
"hexo-generator-category": "^1.0.0",
"hexo-generator-feed": "^2.0.0",
"hexo-generator-index": "^1.0.0",
"hexo-generator-searchdb": "^1.0.8",
"hexo-generator-sitemap": "^1.2.0",
"hexo-generator-tag": "^1.0.0",
"hexo-related-popular-posts": "^3.0.6",
"hexo-renderer-ejs": "^1.0.0",
"hexo-renderer-marked": "^2.0.0",
"hexo-renderer-stylus": "^1.1.0",
"hexo-server": "^1.0.0",
"hexo-symbols-count-time": "^0.6.1",
"hexo-wordcount": "^6.0.1"
}