Power & Source of Big Ideas

problem with garbage collection [SOLVED]

Moderators: chensy, FATechsupport

when work with serial port, after "GC_CONCURRENT" in logcat,
file descriptor "FileImputStream" is "-1 and error "java.io.IOException: read failed: EBADF (Bad file number)"
why? how to solve it?
hey guys, solved...
this method get you a file descriptor >> "int fd = HardwareControler.openSerialPort(......);"
after that create ParcelFileDescriptor >> "pfd = ParcelFileDescriptor.fromFd(fd);"
and then create FileInputStream >> "FileInputStream mFileInputStream = new FileInputStream(pfd.getFileDescriptor());"

Note: if "ParcelFileDescriptor" is in method scope after garbage collection, file descriptor of FileInputStream change to "-1"
then "ParcelFileDescriptor" must in class scope.

Who is online

In total there are 7 users online :: 0 registered, 0 hidden and 7 guests (based on users active over the past 5 minutes)
Most users ever online was 5185 on Wed Jan 22, 2020 1:44 pm

Users browsing this forum: No registered users and 7 guests