Questions tagged [dynamic-memory-allocation]
Dynamic memory allocation, usually in the context of languages without garbage collection or mandatory or automatic reference counting, refers to the process or asking the operating system for a variable sized block of memory.
dynamic-memory-allocation
3,629
questions
1
vote
0
answers
54
views
Examining uninitialized heap memory, strange transition at size 1044472 [duplicate]
In the following C++ program I am examining how many bytes are zeroed in the uninitialized heap memory.
#include <cstdio>
#include <string>
static void CountZerosNonZeros(size_t nBytes)
{
...
0
votes
0
answers
67
views
How do I solve "realloc(): invalid next size" error?
Here is the section of code where my program crashes:
if (fromNode != toNode) {
pthread_mutex_lock(&mtxs[fromNode]);
g->out[fromNode]++;
if (g->in[toNode].index == g->in[...
0
votes
1
answer
65
views
Segmentation fault on copy custom dynamic array [duplicate]
I'm trying to implement my custom dynamic array, like std::vector.
Dynamic array module code:
#ifndef ARRAY_H
#define ARRAY_H
#include <cstdlib>
#define CAPACITY_SCALE_FACTOR 2
template <...
0
votes
0
answers
38
views
How do I dynamically allocate memory for a multidimentional array in C? [duplicate]
Dynamically allocate memory for a multidimensional array (matrix) with a specified number of rows and columns.
How to allocate memory?
How to allocate memory for 2D array?
How to dynamically allocate ...
0
votes
0
answers
14
views
How to Comparing Custom Malloc Package (CMU Malloc) with Standard Allocators Using Benchmarks
I am currently working on the CMU Malloc Lab and I have implemented my own malloc package in mm.c. I would like to benchmark my implementation not only with the Malloc Lab grading script but also ...
0
votes
1
answer
28
views
Why in Xcode debugger and instruments some memory is just "malloc(48 bytes)"
This, but meanwhile, other objects have fully qualified ObjectiveC class names, Swift class names, etc.
Why are some allocations written as "malloc(48 bytes)", while others aren't? Does this ...
0
votes
1
answer
84
views
How can I prevent newly added users from having their age increased in the same iteration in a linked list in C?
I'm creating a Linked List of Users where one of the field is int age;
The user can choose from several options (addUser, findUser, exit, etc.)
on each iteration of the while loop I want to increase ...
0
votes
1
answer
32
views
Does Spark 3.X on kubernetes supports dynamic allocation
We are using EKS master as spark master and as of now we are using fixed number of executors.
Now we want to enable dynamic allocation, does it supports in case of EKS.
I've seen some blogs saying to ...
0
votes
1
answer
80
views
Why Can't I Successfully Allocate Space for a 1D Array Anywhere Besides Main? [duplicate]
I'm working with my professor's code that makes a list of 30 random numbers, and it started throwing errors when I tried to run it. I noticed that when I printed out the array contents within the ...
0
votes
1
answer
57
views
Segfault with memcpy and array
I'm learning C and just ironing out my understanding of how memory is allocated. I'm playing around with the following code and it's segfaulting but I'm not sure why. Any pointers? (no pun intended)
#...
0
votes
2
answers
55
views
Why can't I reassign flexible array member?
I have the following struct with a flexible array member. However, the code does not compile:
#define INITIAL_CAPACITY 5
typedef struct Object {
int size;
int elements[];
} Object;
int main(...
1
vote
1
answer
49
views
Segmentation fault in using recursive selection sort in C language
I have i have wrote a C program. It should use recursive selection sort but segmentation fault occurs for big input (10000 or more). Debugger says that the segfault happens in findim function, but it'...
2
votes
1
answer
86
views
Does redim use the heap or the stack memory in VBA?
I know this is quite strange to ask for a language that is far from a low-level language such as C and C++, but it caught my attention that for example if I do this:
Dim tempArray(0 To 2) As Integer
...
2
votes
2
answers
124
views
Unexpected result of string concatenation in C
The following C program should append an "/" after the path received in argv if the argument does not end in "/". The "odd for me" behavior is that after the first ...
0
votes
1
answer
65
views
How to default initialise non-POD object onto same address?
tl;dr; How can one make every instance of object have same constant address, and then assign it after user wants to change it?
I have a need to develop my own NULL (ish) objects, and would like to ...