Questions tagged [alloc]
207 questions
0
votes
2 answers
Conditional alloc/dealloc? [Objective-c and Cocos2D]
What if I want to alloc a class inside another and I want to reference it easily, but sometimes this class would not need to be alloc'd, therefore not dealloc'd. How is this done? Can I put a conditional inside dealloc so it doesn't have to be…

Chewie The Chorkie
- 4,896
- 9
- 46
- 90
0
votes
2 answers
NSString init or alloc error?
I have this interface:
#import
@interface Cards : NSObject { NSString* effect; NSString* image; }
-(NSString*) effect;
-(NSString*) image;
-(void) setEffect: (NSString*) effect2;
-(void) setImage: (NSString*)…

dgTheUser
- 21
- 3
0
votes
1 answer
Questions about a small memory allocation program (41 lines)
Questions
Does the "memory storage array" allocbuf[10] save everything back to back. For example allocbuf[10] is full with {F, i, r, s, t, \0, S, e, c, \0] and I'll state how allocbuf became full. I imagine all of the information I save into…

Renzo M-Svartz
- 13
- 5
0
votes
0 answers
How to access allocation metadata
Here is a code out of curiosity.
I'm trying to figure out how to access my allocation metadata. When I do chunk = second_alloc - sizeof (struct malloc_chunk); I manage to recover information, but if I do chunk = first_alloc - sizeof (struct…

Blue
- 25
- 1
- 4
0
votes
1 answer
Too much heap memory usage when reallocing
Valgrind says that 42 718 bytes were allocated, however, when I see how many times the reallocation procces is called, it's 3 or 6 times and variables currentLength and currentLineLength are 10 20 30 or 10 20 30 40 50 60, so the problem isn't in the…

tomashauser
- 561
- 3
- 16
0
votes
3 answers
Objective-C class inheritance and allocation
Given the line below where Square is a subclass of Rectangle:
Rectangle *thisObject = [[Square alloc] init];
thisObject contains:
1. All the instance variables of a Square object.
2. All the instance methods implemented in the Square object.
3. …

user523234
- 14,323
- 10
- 62
- 102
0
votes
5 answers
objective-c: alloc vs synthesise/retain
I have a beginner's question. I would like to have access to an UIView in all parts of my code (as opposed to a single method/function).
I therefore declared it in the @interface section
UIView *calendarView;
and then @property (nonatomic, retain)…

n.evermind
- 11,944
- 19
- 78
- 122
0
votes
2 answers
When declaring a new String Object, is it necessary to instantiate it first?
Is it necessary to do instantiation for a new string object as the following code shows:
NSString *newText = [[NSString alloc] initWithFormat:@"%@",sender.titleLabel.text];
Or can we simply run the following code:
NSString *newText =…

Zhen
- 12,361
- 38
- 122
- 199
0
votes
0 answers
What is the fastest way to initialize newly allocated memory in C++?
I'm trying to allocate and use 100 MB of data (size_t s = 100 * 1024 * 1024) and measured different ways in C++:
Raw allocation without init:
// < 0.01 ms
auto p = new char[s];
C++ zero-init:
// 20 ms
auto p = new char[s]();
Manual zero-init:
//…

Artificial Mind
- 945
- 6
- 19
0
votes
1 answer
Understanding memory allocations and pointers in c
I am trying to deepen my understanding on Operating systems. My Linux system uses a page size of 4096 bytes. I got that from running the command:
[root@localhost]# getconf PAGESIZE
4096
I also know that a page is the least addressable memory unit.…

aboria
- 123
- 6
0
votes
0 answers
Memory allocation of a very large block always possible?
If I make a std::vector which nearly as large as the heap size of the process is, what happens if there is a small chunk of memory allocted just in the middle of the heap?
Will the "alloc" call be successful and the memory management of the…

Ernie Mur
- 481
- 3
- 18
0
votes
1 answer
alloc implementation in c programming
#define ALLOCSIZE 10000 /* size of available space */
static char allocbuff[ALLOCSIZE]; /* STORAGE FOR alloc */
static char *allocp = allocbuff; /* next free position */
char *alloc(int n) /* return pointer to n characters */
{
…

sri harsha
- 23
- 1
- 8
0
votes
4 answers
how can I allocate and initialize an object, so it should not reload again when ViewDidLoad Loads?
I have initialized an delegate object in ViewDidLoad of my ViewController, but when I am again loading it, it is initializing the value again.
I am saving some some sort of array in that delegate object which I want to access using getObject and…

Chatar Veer Suthar
- 15,541
- 26
- 90
- 154
0
votes
1 answer
Is there a way to allocate memory in a .NET process that is "executable"?
I was wondering if there is any way to allocate memory in a process and have that memory be r/w & executable?
I found System.Runtime.InteropServices.Marshal.AllocHGlobal, dunno if that the thing I am looking for, if so then how does it work? I don't…

JazzEX
- 119
- 1
- 2
- 6
0
votes
0 answers
C++ way to override basic_string
I am using gcc 2.95.3 to support a legacy system that uses multi-threaded application. STL implementation for basic_string is not threadsafe and STL implementation for __default_alloc_template::allocate(unsigned int) too. If I could…

Dr. Debasish Jana
- 6,980
- 4
- 30
- 69