Questions tagged [resource-management]
142 questions
5
votes
3 answers
MySQLdb Best Practices
I'm currently developing a Python script that does a few things with some data pulled from a MySQL database. To access this data, I'm using the module MySQLdb.
This module follows the guidelines laid out in PEP 249, the Python DB API, and involves…

Patrick Perini
- 22,555
- 12
- 59
- 88
5
votes
1 answer
Why does condition_variable_any needs a mutex managed by a shared_ptr?
The implementation of std::conditional_variable_any needs (in gcc and clang) a std::shared_ptr.
Inside the wait methods, the lifetime of the mutex will be extended to the local scope.
template
void
wait(_Lock& __lock)
…

Viatorus
- 1,804
- 1
- 18
- 41
5
votes
3 answers
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 */ }
//...
public void Close() { /* calls .Dispose(); */ }
}
Is there a good way to…

Paul
- 6,188
- 1
- 41
- 63
5
votes
7 answers
What is the relationship between the using keyword and the IDisposable interface?
If I am using the using keyword, do I still have to implement IDisposable?

Troy
- 1,659
- 4
- 19
- 33
5
votes
1 answer
Mixing cpu-shares and cpuset-cpus in Docker
I would like to run two containers with the following resource allocation:
Container "C1": reserved cpu1, shared cpu2 with 20 cpu-shares
Container "C2": reserved cpu3, shared cpu2 with 80 cpu-shares
If I run the two containers in this way:
docker…

Giovanni Quattrocchi
- 51
- 2
5
votes
3 answers
When does std::shared_ptr release its object?
I'm on Ubuntu 14.04 using GCC 4.8.4 and I have code similar to the following:
std::shared_ptr my_shared_object = set elsewhere...
MyFunction(*my_shared_object);
Where MyFunction's signature looks like this:
void MyFunction(const MyClass&…

kip622
- 399
- 5
- 16
5
votes
4 answers
IDisposable chain
If I implement a object with IDisposable, should all objects that own that object implement it as well, even if they have no other resources to release?

C. Ross
- 31,137
- 42
- 147
- 238
4
votes
1 answer
How do I clean up after my Daemon?
I am running a local instance of HTTP::Daemon using a modified version of the looping structure outlined in the documentation. I have made it possible to exit the loop at the user's request, but a subsequent execution of my Perl script gives me the…

fbrereto
- 35,429
- 19
- 126
- 178
4
votes
2 answers
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 classes and types from the code. Fortunately…

Christopher Currens
- 29,917
- 5
- 57
- 77
4
votes
1 answer
Use both versions of Google cloud resource management Java API in the same project
Currently I'm working on a Java project which needs to have Google Cloud integration.
I need to get all folders and all projects from a service account using Cloud Resource Management API.
The problem is folders are new and only available in…

Shawn Du
- 41
- 1
4
votes
1 answer
How to properly use the custom shared_ptr deleter?
I'm still a little confused about the proper way to use a custom deleter with shared_ptr. I have a ResourceManager class which keeps track of resource allocations, and I modified its interface to support automatic release of used resources by making…

Dejan Nikolic
- 63
- 5
4
votes
6 answers
Returning Smart Pointers
Suppose I had a Manager Class that held a vector of some object:
class SomeObjectManager
{
private:
std::vector _heldObjects;
};
And in that class I had some function that iterated through said vector to return the requested…

Mister
- 487
- 3
- 17
4
votes
8 answers
Using RAII with a character pointer
I see a lot of RAII example classes wrapping around file handles.
I have tried to adapt these examples without luck to a character pointer.
A library that I am using has functions that take the address of a character pointer (declared like…

eric.frederich
- 1,598
- 4
- 17
- 30
4
votes
1 answer
Resource management when using "use" inside a sequence expression
I have a simple sequence expression that makes use of a resource that I'd like to clean up when I'm finished:
type MyObject() =
member this.Items =
seq {
use resource = ResourcePool.Get()
let c =…

JDB
- 25,172
- 5
- 72
- 123
4
votes
1 answer
Comparing weak_ptr to raw pointer doesn't work, looking for alternative
I have a SpriteManager class that loads and caches sprites for me, and removes unused sprites from the cache. That's the idea anyways, I'm a bit stuck. I have a map> where I'm storing the sprites, and use the weak_ptr…

Cubic
- 14,902
- 5
- 47
- 92