Questions tagged [allocation]
The allocation tag has no summary.
35 questions
0votes
2answers
278views
What should I consider when determining what `ALLOC_MAX` should be in this type of I/O loop?
For, e.g. determining an amount of memory that is safe to allocate for processing file or device with this type of I/O loop: HANDLE hFile /* = file open with GENERIC_READ */; LARGE_INTEGER liSize; ...
15votes
6answers
9kviews
Unstable output C++: running the same thing twice gives different output
So, the problem: When I run the same C++ code in Visual Studio, with the same input and parameters, I get either the correct output, or an output that is completely messed up (99% of values go to zero)...
1vote
3answers
295views
What is the standard for heap allocators in bare metal programs?
What is the standard for heap allocation systems in bare metal programs? If there is no standard, what is the most popular one? Is it a free list? If so, are there heuristics that use a hash table of ...
0votes
5answers
235views
Load and process (compressed) data from filesystem in the blink of an eye
We have a huge amount of queries hitting our API that request a minor or major extract of some huge files lying around on our mounted hard drives. The data needs to be extracted from the files and ...
6votes
2answers
2kviews
Why would you use 'new' and 'delete' for something that will be referenced through a vector?
I'm going through some code from this article about ECS-systems in game programming and trying to understand it, and something I'm seeing a lot is using heap memory in places where it seems like ...
0votes
1answer
152views
How do custom allocators know which addresses of memory they can allocate?
I was looking at Rust's Allocator trait. From my understanding, you give an allocator a length of memory and a word size to align to, and the allocator either gives you a pointer to the memory or an ...
1vote
4answers
1kviews
Using output arguments in C++ to avoid dynamic allocations
I have a function that repeatedly encodes Foos to string. I'm currently deciding between two ways to implement this: Return by value: std::string encode(const Foo& foo); void important_function() ...
0votes
3answers
234views
What goes into a computer deciding how many memory locations to assign for specific data types in C?
I have learned file memory management and some very simple CPU assembly for manual memory manipulation. Still, I feel like there is a gap in my knowledge when it comes to modern, complex computers, ...
0votes
4answers
672views
Design pattern for embedding constructor arguments into classes/structs
I am still quite new on here so I hope I am posting in right forum. I am currently writing a small library where I realized I could use some kind of design pattern which lets one pass constructor ...
2votes
1answer
117views
Quantity allocation algorithm performance
I have a scenario for which I'll take an analogous example to help understand better. There are N buckets of known varying capacities. We have M balls that we need to put in these buckets to fill ...
15votes
2answers
7kviews
Why does the base class need to have a virtual destructor here if the derived class allocates no raw dynamic memory?
The following code causes a memory leak: #include <iostream> #include <memory> #include <vector> using namespace std; class base { void virtual initialize_vector() = 0; }; ...
3votes
7answers
2kviews
Is there a best practice for allocation/deallocating multiple, dynamic arrays in C?
I was wondering what would be the best approach to allocate/deallocate multiple one-dimensional, dynamic arrays in C. This seems easy at first, however, for me it turned out to be problematic. ...
26votes
2answers
9kviews
Why can FAT16 not store more than 2 GB?
All the sites I go to look for informations on FAT16 just declaratively state that it can not allocate more than 2 GB. OK. Great. I believe you. But how do you come to that conclusion (other than just ...
-2votes
1answer
901views
First Fit Algorithm Memory Allocation
I am currently reviewing memory partitions and I have a problem that is really confusing me. Suppose you have 5 memory partitions: 100K, 500K, 200K, 300K, and 600K. Also suppose you have 4 ...
1vote
0answers
476views
Constructing a stateful allocator using an interface
I have the following abstract class which implements the "Allocator" concept, using policies and traits to customize behavior: #define FORWARD_ALLOCATOR_TRAITS(C) \ typedef ...