resource-management
Early finalization and memory leaks in C++/CLI library
I\'m having issues with finalizers seemingly being called early in a C++/CLI (and C#) project I\'m working on.This seems to be a very complex problem and I\'m going to be mentioning a lot of different[详细]
2023-04-13 09:04 分类:问答Are Locks AutoCloseable?
Are Locks auto-closeable? That is, instead of: Lock someLock = new ReentrantLock(); someLock.lock(); try[详细]
2023-03-26 03:06 分类:问答Do (POSIX) Operating Systems recover resources after a process crashes?
Let\'s assume we have a process that allocates a socket listening on a specific port, does something with it and then terminates abnormaly. Now a second process starts and wants to allocate a socket l[详细]
2023-03-21 00:57 分类:问答What happens if delete[] p fails?
Suppose I have a pointer to a dynamically allocated array of 10 elements: T* p = new T[10]; Later, I want to release that array:[详细]
2023-03-15 18:20 分类:问答Handling IO exceptions in Java
Basically, I want to open a file, read some bytes, and then close the file. This is what I came up with:[详细]
2023-03-11 03:58 分类:问答Closing a resource stored in Option[ ]
I have a resource object stored in an option. private var ochan: Option[Channel] = None At some point during program execution, ochan is set to Some(channel). I\'d like to close the channel (via i[详细]
2023-02-22 16:45 分类:问答Closing nested Reader
When reading from a text file, one typically creates a FileReader and then nests that in a BufferedReader. Which of the two readers should I close when I\'m done reading? Does it matter?[详细]
2023-02-08 13:53 分类:问答How to deal with a class than encapsulates a disposible instance?
interface IMyInterace { void Open(); object Read(); void Close(); } class MyImplementation : IMyInterface { public void Open() { /* instantiates disposible class */ }[详细]
2023-02-01 16:18 分类:问答sharing a data member with the outside world in a thread-safe manner
I would really appreciate some advise on this matter. e.g. class Foo { TData data; public: TData *getData() { return &data; } // How can we do this in a thread safe manner ?[详细]
2023-01-31 05:36 分类:问答Graceful handing over resources from initramfs to userspace
There are hardware devices which need userspace suppport, like daemon running and handling parts of interaction not suitable (too complex or policy-related) for kernel space.[详细]
2023-01-27 20:36 分类:问答