Questions tagged [allocation]

Memory allocation is an operation of giving a program a block of memory.

1869 questions
0
votes
1 answer

'new' causes std::bad_alloc on relatively not-large allocation

I'm working on a program used to process pictures of circuits close to a 1:1 micrometer:pixel ratio, so I've got quite a few elements in various vectors that are dynamically allocated (via constructor for CImg). Outside of that, I only have a few Qt…
0
votes
4 answers

Storing a char in a char pointer

I have a global variable that is a *char. My main function header reads as int main(int argc, char* argv[argc]){...}. These two lines of code have to remain the way they are. The first argument of my main function is a number of type *char, that I…
0
votes
1 answer

Calling alloc on a pointer

I'm using cocos2d with objective C. I have a class called CrystalineBubble that is currently empty it inherits from CCNode. #import #import "cocos2d.h" @interface CrystalineBubble : CCNode { } @end When I try to…
Tiddly
  • 1,620
  • 3
  • 21
  • 43
0
votes
2 answers

C - Printing a dynamic array

I am creating a program that modifies a dynamic array. It must initialize the array and be able to insert into it. I have been unable print the array after in order to test it, how would I go about this? Piece of relevant code: typedef struct { …
B. Fett
  • 13
  • 1
  • 6
0
votes
4 answers

C dynamic array memory allocation, filling and sorting

I am creating four functions: Allocate memory to an array Generate random chars an fill the array Sort the array into ascending order Print the sorted array Like you will see in the code, I use a printf to see the generated chars. The…
Ion
  • 351
  • 3
  • 19
0
votes
1 answer

Is there a Tcl extension to deal with huge lists, workaround the 2GB allocation limit?

Based a previous node in this site, TCL max size of array it would appear that Tcl cannot handle > 256M elements list. Is there an extension/future plan to overcome this limitation?O/W, I would assume that for the time being, and next foreseeable…
user1134991
  • 3,003
  • 2
  • 25
  • 35
0
votes
1 answer

Memory use in cuda cusp linear solver

I am using cusp::bicgstab to solve a linear system Ax=b, in which A is a 3D Poisson on MxNxP mesh, x is unknowns, and b is the RHS. I have a K40m Tesla which has 12GB memory. I tested with M=2000, N=2000, P=20 (80 millions unknowns), variable type…
PLe
  • 37
  • 7
0
votes
1 answer

Deallocate memory from 2D mixed array and vector

a 2D and 3D array vectors are defined and used throughout a simulation, they are very large in size so deallocation is neccesary. array, n> A; array, n>, m> B; what is the proper way?
jarhead
  • 1,821
  • 4
  • 26
  • 46
0
votes
2 answers

why use the new operator to dynamically allocate memory for a string before assigning, when we can use the = operator to assign a string to it?

I am new to C++ and the concept of strings, why do I have to use the new operator to dynamically allocate resources when I can do it just assigning the string using the = operator ? (this is my first question and sorry for being messy) student(const…
0
votes
5 answers

Simple efficiency question C++ (memory allocation)..and maybe some collision detection help?

I'm writing a little arcade-like game in C++ (a multidirectional 2d space shooter) and I'm finishing up the collision detection part. Here's how I organized it (I just made it up so it might be a shitty system): Every ship is composed of circular…
Chad
  • 2,335
  • 8
  • 29
  • 45
0
votes
1 answer

How do I properly allocate memory in my C program?

I am writing a Windows program in C for a homework assignment and I am running into a problem that causes my program to crash with program.exe has stopped working. I believe that this is due to the memory not being allocated correctly. The program…
Steven
  • 9
  • 3
0
votes
1 answer

iPhone memory leak (a lot of allocations)

I tested my app in Instruments. No leaks found, but app crashes (not immediately - after ~20 minutes [depends on user's activity] of working). I viewed Allocations. It reports: Category | Live Bytes | Count Live | # Living | # Transitory | Overall…
kpower
  • 3,871
  • 4
  • 42
  • 62
0
votes
1 answer

Basic C Matrix segmentation memory allocation

I tried to run this program through the terminal and this error showed up. "Segmentation Fault: 11" I would like to know why . What this program does is, it reads a .ppm file and it saves it's information in a matrix variable of type Pixel, so, a…
Leonardo Dias
  • 71
  • 2
  • 9
0
votes
3 answers

How to allocate memory for a int array in a struct

I have a struct typedef struct { int size; //size of array int array* } How do I allocate memory for the int array using the size variable and malloc?
0
votes
2 answers

How to find Dynamically allocated size in c language?

Write a function to find exact size of dynamically created * variable ? Guys it is working but for static allocation only... int alp=0; printf("%d",(char*)(&alp+1)-(char*)(&alp)); it will return 4 correct size, which is size of int at 32 bit…
srhaider
  • 17
  • 4