Hi,
I'm using a TabBarController with a few Tabs and I have memory problems when switching through the tabs and the contents. Is there a way to release and dealloc everything when I go to another ViewController ?
So when I am in Tab#1 with ViewController #1 and I go to Tab#2 with ViewController #2, how can I free all the memory ViewCont...
I want to be able to browse through heaps of images in the browser, fast. THe easy way (just load 2000 images and scroll) slows down the scrolling a lot, assumedly because there's too much images to be kept in memory.
I'd love to hear thoughts on strategies to be able to quickly scroll through 10000s of images (as if you were on your d...
I have a multidimensional array. The array itself is fine. My problem is that the script takes up monster amounts of memory, and since I'm running this on my MAMP install on my iBook G4, my computer freezes up. Below is the full script.
$query = "SELECT * FROM posts ORDER BY id DESC LIMIT 10";
$result = mysql_query($query);
$posts = ar...
Hi all,
Mac OS X 10.6, Cocoa project, with retain/release gc
I've got a function which:
iterates over a specific directory, scans it for subfolders (included nested ones), builds an NSMutableArray of strings (one string per found subfolder path), and returns that array.
e.g. (error handling removed for brevity).
NSMutableArray * ...
NSString *myString = @"Hello";
NSString *myString = [NSString stringWithString:@"Hello"];
I understand that using method (1) creates a pointer to a string literal that is defined as static memory (and cannot be deallocated) and that using (2) creates an NSString object that will be autoreleased.
Is using method (1) bad?
What are t...
Hello all -
I am learning Obj-C but still occasionally have a difficult time wrapping my head around some of the mem management stuff. I am using custom cells with a UITableView, and implemented the cellForRowAtIndexPath method where I accidentally released the cell at the end. This obviously caused problems as the cell was also gettin...
OK, this may sound weird, but here goes.
There are 2 computers, A (Pentium D) and B (Quad Core) with almost the same amount of RAM running Windows XP.
If I run the same code on both computers, the allocated private bytes in A never goes down resulting in a crash later on. In B it looks like the private bytes is constantly deallocated a...
Are there ways at determining the total size of a complex object in .NET? This object is composed of other objects and might hold references to other complex objects. Some of the objects encapsulated by this object might be POD, others may not.
...
Consider the following example:
#include <iostream>
#include <sstream>
#include <vector>
#include <wchar.h>
#include <stdlib.h>
using namespace std;
struct odp {
int f;
wchar_t* pstr;
};
int main()
{
vector<odp> vec;
ostringstream ss;
wchar_t base[5];
wcscpy_s(base, L"1234");
for (int i = 0; i < 4; i++)...
Hey guys, suppose the following code:
int main (int argc, const char * argv[])
{
//[...]
Rectangle* myRect = [[Rectangle alloc] init];
Vector2* newOrigin = [[[Vector2 alloc] init] autorelease]; // ref count 1
[newOrigin setX: 50.0f];
[myRect setOrigin: newOrigin]; // ref count 2
[myRect.origin setXY: 25.0f :1...
I think i have an UIImage that has a higher retain count than it should have and i am probably leaking memory. I use this image as a thumbnail, to set a custom background to a uibutton. So the uibutton is holding a reference to it and so do i. But instead of 2, the retainCount is 3. Do i have to create a custom UIImage derived class and ...
Hi,
If I have a vector<string*> *vect or a map<pair<string*, int*>, string*> *map,
how to clean up everything (including all object the vector/map contains)?
(Everything (vector, map, contents, string, ints) is allocated with new)
Is
delete vect;
delete map;
enough?
...
At various points during my application's workflow, I need so show a view. That view is quite memory intensive, so I want it to be deallocated when it gets discarded by the user. So, I wrote the following code:
- (MyView *)myView {
if (myView != nil)
return myView;
myView = [[UIView alloc] initWithFrame:CGRectZero]; // ...
Possible Duplicate:
Testing pointers for validity (C/C++)
If I have a pointer, like char* foo, is there any way to determine if foo points to a valid location in memory? (So, foo is not NULL, and delete has not yet been called on it.)
...
Ok, I know this question seems to have been asked many times on stackoverflow.
but please read
Well the answer for any address is "No you can't" but the question here is to know if a pointer points to a piece of memory allocated with malloc/new.
Actually I think it could be easily implemented overriding malloc/free and keeping track of ...
In objective-c I see a lot of sample code where the author assigns a local variable, assigns it to a property, then releases the local variable. Is there a practical reason for doing this? I've been just assigning directly to the property for the most part. Would that cause a memory leak in any way? I guess I'd like to know if there's an...
In objective-c you are responsible for releasing objects you allocate, but what happens when you allocate an object in a method, assign self as the objects delegate, and then release the object.
The callbacks from the newly created (and released) object fails at this point, or rather, doesn't happen.
- (void)doSomething
{
MyObj *m...
I was looking at someone else's code and noticed they called 'release' on an NSString they didn't own (never called alloc/retain/copy anywhere and it wasn't a property).
This looked a bit strange to me and it made me wonder if any strange behaviour can occur if you call 'release' on an object that you either don't 'own' or whose ref cou...
I see a lot of Objective-C code that has the following syntax when attempting to free objects from memory when they are no longer needed.
[controller release], controller = nil;
Why set the variable to nil after sending the release message? Isn't release going to free the object no matter what? Why does it need to be set to nil as w...
My question are commented in the code
ImageView img = new ImageView();
this.layout.addView(img);
MyObject o = new Object(img);
// Do i need to set img to null?
ArrayList <MyObject> myArray = new ArrayList <MyObject>();
MyObject obj = new MyObject();
myArray.add(obj);
// Do i need to set obj to null?
...