Skip to content

Commit

Permalink
Create FdLeakTrack.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
happylishang committed Aug 16, 2022
1 parent 69ea5f6 commit a079c99
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions collie/src/main/java/com/snail/collie/mem/FdLeakTrack.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.snail.collie.mem

import android.os.Process
import android.system.Os
import android.util.Log
import java.io.File

object FdLeakTrack {

fun collectLeakFds() {
val fdFile = File("/proc/" + Process.myPid() + "/fd/")
val files = fdFile.listFiles()
files?.forEach { file ->
try {
Os.readlink(file.absolutePath);
} catch (e: Exception) {
}
}
}
}

0 comments on commit a079c99

Please sign in to comment.