Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [allocation]

The tag has no usage guidance.

8
votes
2answers
239 views

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; }; ...
4
votes
7answers
237 views

Is there a best practice for allocationg/deallocating multiple, dynamic arrays in C?

I was wondering what would be the best approch to allocate/deallocate multiple one-dimensional, dynamic arrays in C. This seems easy at first , however, for me it turned otu to be problematic Considre ...
25
votes
2answers
6k views

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 ...
-2
votes
1answer
687 views

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 ...
1
vote
0answers
149 views

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 ...
1
vote
4answers
594 views

How does C++ dynamic allocation work?

I have a big doubt about dynamic allocation. Suppose you have a class like this: class MyClass { public: MyClass() {} ~MyClass() {} private: std::vector<...
3
votes
3answers
847 views

Is O(log n) for memory management considered slow?

I am talking about single thread general purpose memory allocation/deallocation from a global 'heap' as e.g. every C programmer knows in the form of malloc()/free(). I can't recite the actual title ...
3
votes
1answer
236 views

How can I efficiently implement batch allocation in a freelist?

I've been implementing Andrei Alexandrescu's allocators as an exercise, but I've gotten stuck on his Freelist. Andrei's Freelist looks something like this: template<class BaseAllocator, std::...
5
votes
4answers
473 views

Storing objects whose size are run-time dependent contiguously in memory

The background I am working on an ECS in C++ for fun and I am trying to make it as efficient as possible. One of the optimisations I am striving to implement is to minimise cache misses by storing ...
0
votes
2answers
97 views

Question answer allocation algorithm

We have a big set of survey questions, which we distribute to users online. We collect submission from users and based on their submission, we decide the answers for those questions. Now, each user ...
1
vote
2answers
803 views

How do Virtual Machines allocate memory?

If I want to allocate a struct in C, #include<stdio.h> typedef struct container { int i; } Container; int main() { Container *ptr_to_container; ptr_to_container = (Container *) ...
2
votes
0answers
60 views

Most efficient way of allocating participants to conference tracks

I am redesigning a system by which conference participants can choose which track they want to attend. Participants express their track preferences arranging them in order and submitting them at a ...
1
vote
1answer
168 views

Static memory idiom

I am on a micro controller (which means I can only have static memory allocation) and I am trying to work with inheritance..... Suppose I have a abstract class Image and an abstract class Font. An ...
1
vote
0answers
98 views

Resource Allocation Algorithm

I have a question about assigning values to nodes laid out in a physical space: There is a set of N fixed nodes spread out throughout a certain 2 dimensional region that need to be assigned a value ...
1
vote
1answer
2k views

Big O notation allocate array of N element

In Big O notation, allocate an array of N element is defined by O(1) or O(n) ? For example in C#, if I allocate an array like this : int[] a = new int[10] When I display this array, I have : {0,0,0,...
6
votes
1answer
281 views

Does assigning NULL in a GC'ed Environment have similar effects to using free()?

I was just writing a function (in C# in this case) that stored huge amounts of data in a local variable early on in the code, let's say at 5% of the functions code. After that point, the data in this ...
8
votes
3answers
6k views

Why std::allocators are not that popular? [closed]

With the latest trends about C and C++ applications, and with latest I mean the latest years, I was expecting to see std::allocators to be used way more frequently than what it really is. Modern ...
0
votes
2answers
4k views

Dynamic initialization, how does it work?

I have a question regarding dynamic initialization. Example code void main() { int a = 100; //Statement1 //Statement2 ... float b = 6.32987; //StatementA ... return; } The StatementA allocates ...
6
votes
2answers
6k views

What is the best solution for static memory allocation?

I'm working on image processing and I need to use big Images in a critical system. A good practice for critical systems is to avoid dynamic allocation of memory but what is the design/recommendations ...
1
vote
0answers
289 views

Development of algorithmical concept for scheduling and allocation problem

I have to solve a problem in the field of operations research. I want to gather some general approaches to evaluate them to pick the most promising to design a problem-related program. Problem ...
1
vote
2answers
6k views

What is a good algorithm for priority allocation of work duties?

I am currently doing a project (in PHP) that has the following requirements: There is a list of people, sorted in a certain priority. Work should be allocated to them by this priority. e.g. If the ...
1
vote
2answers
2k views

How are new[] and malloc implemented in Windows? [closed]

So when you call malloc or new [] from your C/C++ application, how does the CRT translate it into Windows API calls?
1
vote
3answers
359 views

Allocation problem identification

I have a matrix. I have a list of people who have to occupy n1,n2,n3 etc cells, different number of cells in different rows. I have to place the people in the cells. Occupying the same cell across ...
7
votes
2answers
3k views

In c/c++, are block-scope variables stacked only if the block is executed?

Suppose this: void func() { ... if( blah ) { int x; } ... } Is the space for x reserved on the stack immediately when func is entered, or only if the block is actually executed? Or is it ...
5
votes
2answers
360 views

Heaps: Why is there a tradeoff between amount of space occupied (fragmentation), and speed at which operations are carried out?

Apparently, the two major judging criteria of the effectiveness of heaps are (1) how much we can minimize the amount of space it takes up and (2) how fast operations on the heap can be carried out, eg,...