Memory allocation is an operation of giving a program a block of memory.
Questions tagged [allocation]
1869 questions
0
votes
4 answers
How memory is allocated when we use malloc to create 2-dimensional array?
I want to create an integer array[5][10] using malloc(). The difference between memory address of array[0] and array[1] is showing 8. Why?
#include
#include
int main() {
int *b[5];
for (int loop = 0; loop < 5; loop++)
…

Shivind
- 67
- 7
0
votes
1 answer
AVPlayerItemVideoOutput.copyPixelBuffer fails with EXC_BAD_ACCESS
I've that function:
func retrievePixelBufferToDraw() -> CVPixelBuffer? {
let time = self.playerItem!.currentTime()
// this line is just added to make sure I can call something on self.videoOutput!
…

Guig
- 9,891
- 7
- 64
- 126
0
votes
0 answers
PGI FORTRAN90 allocating an array passed to a subroutine (seg fault)
Here is some fortran90 code that I'm compiling using the PGI fortran compiler. I can't seem to allocate the array within the subroutine arraySub() without seg faulting. It also seg faults if I even check if the array is allocated like this:…

GPSmaster
- 844
- 3
- 15
- 31
0
votes
3 answers
Is there a way to print the amount of heap memory an object has allocated?
In a running program, how can I track/print the amount of heap memory an object has allocated?
For example:
#include
#include
int main(){
std::vector v;
std::cout << heap_sizeof(v) << '\n';
for (int i = 0; i <…

Trevor Hickey
- 36,288
- 32
- 162
- 271
0
votes
2 answers
Dynamically Allocate Cache Size to Alleviate HeapSpace Error
We have a collection of objects which grows quite large over time. We have implemented a caching strategy to help alleviate this, however we are still running out of Heap Space at run time - if enough memory isn't allocated at startup.
Is there a…

Scott
- 9,458
- 7
- 54
- 81
0
votes
3 answers
Array of struct with different length array members C
I am implementing some lookup data in C99 (as a C-Script in the Software PLECS).
I want to create an array of struct with one (later this will be three) array members that will have a different (but always known) length for each struct. I would like…

Rolf Loewenherz
- 43
- 6
0
votes
3 answers
How to init a double**?
I need to init/use a double ** (decleared in my header):
double **pSamples;
allocating (during the time) a matrix of NxM, where N and M are get from two function:
const unsigned int N = myObect.GetN();
const unsigned int M = myObect.GetM();
For…

markzzz
- 47,390
- 120
- 299
- 507
0
votes
1 answer
MATLAB: how to allocate an array of structure data
I would like to create an array of structure, each one of them will have 4 fields that will be an array of unspecified length.
my_struct_data.field1=a;
my_struct_data.field2=b;
my_struct_data.field3=c;
my_struct_data.field4=d;
I am planning, in…

Lorenzo Meneghetti
- 134
- 1
- 7
0
votes
0 answers
Qt QVector allocation via resize() results in bad_alloc where reserve() seems to work
So I want to allocate 1GB of data in QVector. So far I use something like this:
void foo (float* data, size_t size)
{
QVector resultVec;
resultVec.resize(size);
//I do some stuff on the vector
size_t paddingLength =…

FreddyKay
- 275
- 1
- 4
- 13
0
votes
0 answers
Are variables consuming different memory blocks in servers for each user?
Let us suppose there is a php script in our server and we have something like
written. When I open the php page, it should create an instance then…

Mehmet Cetin
- 53
- 6
0
votes
2 answers
Base class should be explicitly initialized in the copy constructor
I've seen answers for this in other topics on Stack Overflow, but I'm not sure what to do in my case. I'm brand new to templates and this is the first template I've /ever/ created using examples found, again, from this website. Anyhow, here is the…

Phobos D'thorga
- 439
- 5
- 17
0
votes
0 answers
RAM Usage grows without doing anything in my app
when I am starting my app I am setting a few Texts and Fonts in some TextViews and I am setting the Content View. When I am looking at the RAM Usage it grows linear:
The allocation Shows many same Threads which cause a huge RAM usage:
Could…

Chinaedu Onwukwe
- 437
- 1
- 7
- 20
0
votes
3 answers
Dynamically allocated member variable. What's the point?
I'm totally new to C++. I would like to ask about the following.
If a member variable is dynamically allocated in the constructor. Should it always be deleted in destructor? If so, then how is the variable's lifetime "elongated"? If not, how should…

D.Badawi
- 175
- 1
- 13
0
votes
0 answers
init UILabel with UILabel
I want to know If I can initialize a UILabel from another initialized UILabel Like this :
_brandNameLabel = [[SharedDataObject shared]brandNameLabel];
[[self view]addSubview:_brandNameLabel];
I found that this code will create a pointer to the…

OXXY
- 1,047
- 2
- 18
- 43
0
votes
0 answers
Is there a reason that many database admins use sizes of 2^n when creating database tables?
Whenever I look through SQL table descriptions, I pretty much always see column data sizes of 2^n. (e.g. 8, 16, 64, 256, etc). I know that due to the nature of binary and the fact that bytes are 8 bits long, 2^n is common to use in computing. But…

jros
- 714
- 1
- 10
- 33