-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
启用StrictMode后,检测到有问题 #6
Comments
|
@huangyanan 解决了吗?说下方案 |
@JackyAndroid 解决了,关注一下那个socket 对象的初始化和关闭,初始化的socket并没有被关闭。 |
@huangyanan
|
无发现异常影响,我这边线上已经使用修改一年了。 |
strictmode 设置如下:
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
.build());
下面是strictmode 输出的信息,这块儿代码仅仅是修改了包名。
10-18 11:29:12.095 17675-17685/com.beibo.yuerbao E/StrictMode: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:180)
at java.net.AbstractPlainSocketImpl.create(AbstractPlainSocketImpl.java:103)
at java.net.Socket.createImpl(Socket.java:451)
at java.net.Socket.connect(Socket.java:584)
at com.husor.dns.dnscache.speedtest.impl.Socket80Test.speedTest(Socket80Test.java:20)
at com.husor.dns.dnscache.speedtest.SpeedtestManager.speedTest(SpeedtestManager.java:58)
at com.husor.dns.dnscache.DNSCache$SpeedTestTask.updateSpeedInfo(DNSCache.java:359)
at com.husor.dns.dnscache.DNSCache$SpeedTestTask.run(DNSCache.java:346)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
The text was updated successfully, but these errors were encountered: