resource-leak

boost::process system leaking file descriptors

夙愿已清 提交于 2021-02-10 03:10:13
问题 It seems like boost::process::system is leaking fds: Let's say I have this simple code to flush iptables config every 3 seconds (just an example): #include <boost/process.hpp> #include <thread> int main(void) { while(true) { std::this_thread::sleep_for(std::chrono::seconds(3)); boost::process::system(boost::process::search_path("iptables"), "-F"); } return 0; } If I observe the count of open file descriptors by listing /proc/PID/fd |wc -l , I can see that the count increases by one every 3

boost::process system leaking file descriptors

帅比萌擦擦* 提交于 2021-02-10 03:08:44
问题 It seems like boost::process::system is leaking fds: Let's say I have this simple code to flush iptables config every 3 seconds (just an example): #include <boost/process.hpp> #include <thread> int main(void) { while(true) { std::this_thread::sleep_for(std::chrono::seconds(3)); boost::process::system(boost::process::search_path("iptables"), "-F"); } return 0; } If I observe the count of open file descriptors by listing /proc/PID/fd |wc -l , I can see that the count increases by one every 3

boost::process system leaking file descriptors

一笑奈何 提交于 2021-02-10 03:07:58
问题 It seems like boost::process::system is leaking fds: Let's say I have this simple code to flush iptables config every 3 seconds (just an example): #include <boost/process.hpp> #include <thread> int main(void) { while(true) { std::this_thread::sleep_for(std::chrono::seconds(3)); boost::process::system(boost::process::search_path("iptables"), "-F"); } return 0; } If I observe the count of open file descriptors by listing /proc/PID/fd |wc -l , I can see that the count increases by one every 3

Why does this code generate a “Potential resource leak” warning?

南楼画角 提交于 2020-01-01 09:34:28
问题 Eclipse (Juno) gives the following warning: Potential resource leak: 'os' may not be closed at the first line of the try body in this code: static void saveDetails(byte[] detailsData) { OutputStream os = null; try { os = sContext.openFileOutput(DETAILS_FILE_NAME, Context.MODE_PRIVATE); os.write(detailsData); } catch (IOException e) { Log.w(LOG_TAG, "Unable to save details", e); } finally { if (os != null) { try { os.close(); } catch (IOException ignored) { } } } } The method openFileOutput is

When should I free the native (Android NDK) handles?

拈花ヽ惹草 提交于 2019-12-25 08:57:38
问题 I have to use a native library (this is not my decision). The library already has a JNI wrapper, and the example Android NDK code works. But the library initialization routines return native handles and the developer is required to correctly close them . Now, there's an interesting question: where to call the close_handle routines from? At least in theory, each incorrect termination may result in temporary files left somewhere on the disk or some other kind of resource leak. Library

RenderTargetBitmap GDI handle leak in Master-Details view

喜夏-厌秋 提交于 2019-12-21 03:42:13
问题 I have an app with a Master-Details view. When you select an item from the 'master' list, it populates the 'details' area with some images (created via RenderTargetBitmap). Each time I select a different master item from the list, the number of GDI handles in use by my app (as reported in Process Explorer) goes up - and eventually falls over (or sometimes locks up) at 10,000 GDI handles in use. I'm at a loss on how to fix this, so any suggestions on what I'm doing wrong (or just suggestions

What can cause section handle leaks?

北城余情 提交于 2019-12-18 05:54:08
问题 This is a follow-up question to my previous question. As suggested in this answer to my previous question, I used ProcessExplorer to analyze a list of handles that my application is using to find a handle leak. The handles that are leaking are of type Section . What exactly is a section handle, where is it used and what can cause section handles to leak? I'm not using memory mapped files in my code. 回答1: Quoting Mark Russinovich's Inside Windows 2000 (what is now called Windows Internals),

Resource leak warning in eclipse

北城以北 提交于 2019-12-17 18:52:01
问题 In Eclipse I received a warning Resource leak: 'ps' is not closed at this location that I don't understand. In my Java code I declare the "ps" as a Prepared Statement and I use (and close) it many times. Then I've the following sequence: try { if(condition) { ps = c.prepareStatement("UPDATE 1 ..."); } else { ps = c.prepareStatement("UPDATE 2 ..."); } ps.executeUpdate(); } catch (SQLException e) { // exception handling } finally { if (null != ps) try { ps.close(); } catch (SQLException e) { //

What's the upper limit on GDI objects for one process in Windows 7?

梦想与她 提交于 2019-12-17 09:43:45
问题 Have an application with a GDI leak that will eventually hit 10,000 allocated GDI objects and crash. I tried increasing the GDIProcessHandleQuota to 20,000, but the program still crashed when it reached 10,000 objects. We're currently working on patching this leak, but out of curiosity--is there a way to increase the GDI limit for a single process? Or is 10k an individual application's hard limit? 回答1: There is a solution that might work. I deal with a misbehaved vendor's app here that

JAI create seems to leave file descriptors open

a 夏天 提交于 2019-12-13 12:29:21
问题 I have some old code that was working until recently, but seems to barf now that it runs on a new server using OpenJDK 6 rather than Java SE 6. The problem seems to revolve around JAI.create. I have jpeg files which I scale and convert to png files. This code used to work with no leaks, but now that the move has been made to a box running OpenJDK, the file descriptors seem to never close, and I see more and more tmp files accumulate in the tmp directory on the server. These are not files I