Questions tagged [allocation]
Memory allocation is an operation of giving a program a block of memory.
allocation
1,887
questions
0
votes
1
answer
30
views
Jupyter Notebook error: Unable to allocate / Too large work array required, when calculating inverse matrix
I want to calculate the (generalized) inverse of a 30807 x 30807 matrix.
I tried to use np.linalg.pinv(matrix), and the error "MemoryError: Unable to allocate 7.07 GiB for an array with shape (...
2
votes
2
answers
59
views
How to create an uninitialized 2D array?
C# allows you to create an array without it being initialized with GC.AllocateUnitializedArray<T>. T can be any type, such as bool or int. However, I do not know of a way to do this to a 2D ...
1
vote
1
answer
49
views
Why does this allocatable array cause an error?
I don't entirely understand allocation, so this may be a simple problem, but I wrote this Fortran code:
program name
implicit none
integer :: A, B
integer, dimension(:), allocatable :: ARR
...
0
votes
0
answers
41
views
Fortran pointers and allocated arrays, what happens after a "deallocate"? [duplicate]
The following little code compiles and runs w/o error, and gives expected results:
$ cat ptrpractice.F90
program ptrpractice
integer, allocatable, target :: c(:)
integer, pointer :: d(:)
allocate(c(...
-1
votes
1
answer
141
views
allocate as std::byte[10], deallocate as short*
I come to C and C++ from Assembly before 2.5 decades.
I inherited some things implied in assembly, to both C and C++, but later I realized that these things are actually undefined behavior.
One of ...
1
vote
2
answers
101
views
When to use ReadOnlySpan<T> vs explicit / overloaded types [closed]
For the sake of the ensuing question, assume hypothetically that I want to convert a plain-text string into a hexadecimal string; for example, "Hello, World!" into "...
0
votes
0
answers
35
views
Buddy Algorithm free-function
I am trying to implement the function that frees a block in the buddy algorithm. Until now, I have the following code:
int buddy_free(struct block *block)
{
switch (block->refcnt) {
case 0:
...
-3
votes
2
answers
123
views
Why is there no time cost to large stack allocations
I tried this quick-bench test and I'm finding that it's the same cost timewise to allocate 200 bytes as it is to allocate 2000000 bytes.
How could that possibly be?
0
votes
1
answer
46
views
Boxing allocation in Composite Formatting
In Rider Resharper suggests to simplify string interpolation.
When doing so, the Heap Allocation Viewer plugin warns me about boxing allocation. And indeed, the IL code is different and when running ...
0
votes
1
answer
83
views
Why is a nested allocator in Rust causing heap corruption?
I've been experimenting with the Rust allocator_api feature and have developed a simple linear allocator. My test cases show this works as expected. However, I want to be able to nest allocators, e.g.:...
3
votes
1
answer
92
views
C++ size of allocated array extraced memory close to returned pointer from malloc
I have lately been experimenting with overloading the new and delete operators, and I noticed something very interesing.
When I allocate, let's say, class T with new T(); vs new T[1](), there is a ...
0
votes
2
answers
105
views
Using if directives in headers
I have a working generic graph. The type for vertex is currently defined as:
typedef struct vertex {
void *data;
char *label;
bool inGraph;
} vertex;
The void pointer can then be customized for ...
0
votes
0
answers
50
views
Is there a chance to use a custom std::pmr::polymorphic_allocator to make std::unordered_map’s buckets implemented as arrays?
While liked-list buckets implementation in std::unordered_map works well when one needs to add/remove elements from the container, it still could be speed up significantly if “stable” or “read-only” ...
0
votes
1
answer
87
views
C++ Dynamic allocation in while(true) [closed]
I'm a beginner in C++, and I don't understand why I can't make this kind of while loop :
#include <iostream>
using namespace std;
const int gridRows = 3;
const int gridColumns = 3;
string **...
1
vote
2
answers
71
views
Reallocation of global variable in C
As I understand, when function is called from translation unit and this function uses global variable of this translation unit, variable address is unchangable. In case of recalling function from this ...