Skip to content

Instantly share code, notes, and snippets.

young yangdm0209

Block or report user

Report or block yangdm0209

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yangdm0209
yangdm0209 / @SuppressLint("HandlerLeak").md
Created Jun 16, 2016
Android 中handler的HandlerLeak问题
View @SuppressLint("HandlerLeak").md

原因:Handler在Android中用于消息的发送与异步处理,常常在Activity中作为一个匿名内部类来定义,此时Handler会隐式地持有一个外部类对象(通常是一个Activity)的引用。当Activity已经被用户关闭时,由于Handler持有Activity的引用造成Activity无法被GC回收,这样容易造成内存泄露。 正确的做法是将其定义成一个静态内部类(此时不会持有外部类对象的引用),在构造方法中传入Activity并对Activity对象增加一个弱引用,这样Activity被用户关闭之后,即便异步消息还未处理完毕,Activity也能够被GC回收,从而避免了内存泄露。

    public static class MyHandler extends Handler {
        private WeakReference<Activity> reference;
        
        public MyHandler(Activity activity) {
            reference = new WeakReference<Activity>(activity);
        }
View Linux操作备忘录.md

1. 刚刚编译安装完成的库,却提示找不到这个库,这个时候需要手动执行一下ldconfig命令

ldconfig 命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态 链接库,进而创建出动态装入程序(ld.so)所需的连接和缓存文件。缓存文件默认为 /etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表。

ldconfig 通常在系统启动时运行,而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。

@yangdm0209
yangdm0209 / get-mumble.sh
Created May 16, 2016 — forked from weswigham/get-mumble.sh
D/l and build mumble from source on centos
View get-mumble.sh
# Install so many prerequisite libraries:
sudo yum groupinstall "Development tools"
sudo yum install openssl-devel git qt-devel boost boost-devel libsndfile-devel avahi avahi-compat-libdns_sd avahi-compat-libdns_sd-devel protobuf-compiler protobuf-devel gettext gettext-devel festival libtool-ltdl-devel libffi-devel pcre-devel readline-devel automake libtool gtk-devel intltool dotconf speech-dispatcher speech-dispatcher-devel alsa-lib-devel libdaemon-devel libusb-devel libtool rpm-build
# Clone the client’s source:
cd ~
git clone https://github.com/mumble-voip/mumble.git
cd mumble
# Checkout a stable revision:
git checkout 1.2.x
# Build the makefile:
@yangdm0209
yangdm0209 / logger.py
Created May 16, 2016
Python logger wrap
View logger.py
#!/usr/bin/env python
# coding: utf-8
import logging.handlers
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
rht = logging.handlers.TimedRotatingFileHandler("reindex_out.log", 'D')
You can’t perform that action at this time.