Search Results

Search found 12267 results on 491 pages for 'out of memory'.

Page 140/491 | < Previous Page | 136 137 138 139 140 141 142 143 144 145 146 147  | Next Page >

  • Returning a local object from a function

    - by pocoa
    Is this the right way to return an object from a function? Car getCar(string model, int year) { Car c(model, year); return c; } void displayCar(Car &car) { cout << car.getModel() << ", " << car.getYear() << endl; } displayCar(getCar("Honda", 1999)); I'm getting an error, "taking address of temporary". Should I use this way: Car &getCar(string model, int year) { Car c(model, year); return c; }

    Read the article

  • iPhone crashing when presenting modal view controller

    - by Michael Waterfall
    I'm trying to display a modal view straight after another view has been presented modally (the second is a loading view that appears). - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Show load LoadViewController *loader = [[LoadViewController alloc] init]; [self presentModalViewController: loader animated:NO]; [loader release]; } But when I do this I get a "Program received signal: "EXC_BAD_ACCESS"." error. The stack trace is: 0 0x30b43234 in -[UIWindowController transitionViewDidComplete:fromView:toView:] 1 0x3095828e in -[UITransitionView notifyDidCompleteTransition:] 2 0x3091af0d in -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] 3 0x3091ad7c in -[UIViewAnimationState animationDidStop:finished:] 4 0x0051e331 in run_animation_callbacks 5 0x0051e109 in CA::timer_callback 6 0x302454a0 in CFRunLoopRunSpecific 7 0x30244628 in CFRunLoopRunInMode 8 0x32044c31 in GSEventRunModal 9 0x32044cf6 in GSEventRun 10 0x309021ee in UIApplicationMain 11 0x00002154 in main at main.m:14 Any ideas? I'm totally stumped! The loading view is empty so there's definitely nothing going on in there that's causing the error. Is it something to do with launching 2 views modally in the same event loop or something? Thanks, Mike Edit: Very strange... I have modified it slightly so that the loading view is shown after a tiny delay, and this works fine! So it appears to be something within the same event loop! - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; // Show load [self performSelector:@selector(doit) withObject:nil afterDelay:0.1]; } - (void)doit { [self presentModalViewController:loader animated:YES]; }

    Read the article

  • Visual C++: Invalid allocation size. How to force the debugger to stop on this message?

    - by James Roth
    The MFC program I am debugging is printing this message in the "Output" window in Visual Studio 9.0: HEAP[AppName.exe]: Invalid allocation size - 99999998 (exceeded 7ffdefff) I'm pretty sure this is due to a bad "new", uninitialized variable or similar error. The question is: how do I get the debugger to stop on this message so that I can view the stack trace and solve the problem?

    Read the article

  • Practicing buffer overflow attack in Ubuntu

    - by wakandan
    I am trying to learn to use buffer overflow attack in Ubuntu. Unfortunately, I cannot turn off Address Space Layout Randomization (ASLR) feature in this OS, which is turned on by default. I have tried some work around found in some fedora books: echo "0" > /proc/sys/kernel/randomize_va_space but for some reason the protection's still there. Please give me some suggestions. Thanks. [edit]Actually the above command was not successful, it said "Permission Denied", even with sudo. How can I fix that? [adding] I kept on getting segmetation fault error when it shows an address in stack. Is it related to non-executable stack in ubuntu :(?

    Read the article

  • Removing DOM event handlers in long-running browser session

    - by Chris Beck
    I have a browser interface with a ul#contacts list on the left and div#contact property panel (email, phone) on the right. Click a contact in the list and my app makes an XHR request to get the contact property HTML fragment and update div#contact.innerHTML. Each contact fragment has an "Edit Contact" link. With JS, I progressively upgrade that link with an event listener that performs an XHR request to replace the static property panel with an in-place edit form. This can happen many times during a single browser session. How should I clean up my "Edit Contact" event listener? Do I need to remove it manually before the form overwrites the property panel? Or is the event listener cleaned up automatically when the contents of div#contact (and the node that I'm listening on) is overwritten? FWIW, I still consider IE6 to be part of my target market.

    Read the article

  • C++ -malign-double compiler flag

    - by Martin
    I need some help on compiler flags in c++. I'm using a library that is a port to linux from windows, that has to be compiled with the -malign-double flag, "for Win32 compatibility". It's my understanding that this mean I absolutely have to compile my own code with this flag as well? How about other .so shared libraries, do they have be recompiled with this flag as well? If so, is there any way around this? I'm a linux newbie (and c++), so even though I tried to recompile all the libraries I'm using for my project, it was just too complicated to recursively find the source for all the libraries and the libraries they're dependent on, and recompile everything.

    Read the article

  • Container for database-like searches

    - by Milan Babuškov
    I'm looking for some STL, boost, or similar container to use the same way indexes are used in databases to search for record using a query like this: select * from table1 where field1 starting with 'X'; or select * from table1 where field1 like 'X%'; I thought about using std::map, but I cannot because I need to search for fields that "start with" some text, and not those that are "equal to". I could create a sorted vector or list and use binary search (breaking the set in 2 in each step by reading the element in the middle and seeing if it's more or less than 'X'), but I wonder if there is some ready-made container I could use without reinventing the wheel?

    Read the article

  • Reference-counted object is used after it is released

    - by EndyVelvet
    Doing code analysis of the project and get the message "Reference-counted object is used after it is released" on the line [defaults setObject: deviceUuid forKey: @ "deviceUuid"]; I watched this topic Obj-C, Reference-counted object is used after it is released? But the solution is not found. ARC disabled. // Get the users Device Model, Display Name, Unique ID, Token & Version Number UIDevice *dev = [UIDevice currentDevice]; NSString *deviceUuid; if ([dev respondsToSelector:@selector(uniqueIdentifier)]) deviceUuid = dev.uniqueIdentifier; else { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; id uuid = [defaults objectForKey:@"deviceUuid"]; if (uuid) deviceUuid = (NSString *)uuid; else { CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL)); deviceUuid = (NSString *)cfUuid; CFRelease(cfUuid); [defaults setObject:deviceUuid forKey:@"deviceUuid"]; } } Please help find the cause.

    Read the article

  • Is it OK to write code after [super dealloc]? (Objective-C)

    - by Richard J. Ross III
    I have a situation in my code, where I cannot clean up my classes objects without first calling [super dealloc]. It is something like this: // Baseclass.m @implmentation Baseclass ... -(void) dealloc { [self _removeAllData]; [aVariableThatBelongsToMe release]; [anotherVariableThatBelongsToMe release]; [super dealloc]; } ... @end This works great. My problem is, when I went to subclass this huge and nasty class (over 2000 lines of gross code), I ran into a problem: when I released my objects before calling [super dealloc] I had zombies running through the code that were activated when I called the [self _removeAllData] method. // Subclass.m @implementation Subclass ... -(void) deallloc { [super dealloc]; [someObjectUsedInTheRemoveAllDataMethod release]; } ... @end This works great, and It didn't require me to refactor any code. My question Is this: Is it safe for me to do this, or should I refactor my code? Or maybe autorelease the objects? I am programming for iPhone if that matters any.

    Read the article

  • UIVIewController not released when view is dismissed

    - by Nelson Ko
    I have a main view, mainWindow, which presents a couple of buttons. Both buttons create a new UIViewController (mapViewController), but one will start a game and the other will resume it. Both buttons are linked via StoryBoard to the same View. They are segued to modal views as I'm not using the NavigationController. So in a typical game, if a person starts a game, but then goes back to the main menu, he triggers: [self dismissViewControllerAnimated:YES completion:nil ]; to return to the main menu. I would assume the view controller is released at this point. The user resumes the game with the second button by opening another instance of mapViewController. What is happening, tho, is some touch events will trigger methods on the original instance (and write status updates to them - therefore invisible to the current view). When I put a breakpoint in the mapViewController code, I can see the instance will be one or the other (one of which should be released). I have tried putting a delegate to the mainWindow clearing the view: [self.delegate clearMapView]; where in the mainWindow - (void) clearMapView{ gameWindow = nil; } I have also tried self.view=nil; in the mapViewController. The mapViewController code contains MVC code, where the model is static. I wonder if this may prevent ARC from releasing the view. The model.m contains: static CanShieldModel *sharedInstance; + (CanShieldModel *) sharedModel { @synchronized(self) { if (!sharedInstance) sharedInstance = [[CanShieldModel alloc] init]; return sharedInstance; } return sharedInstance; } Another post which may have a lead, but so far not successful, is UIViewController not being released when popped I have in ViewDidLoad: // checks to see if app goes inactive - saves. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resignActive) name:UIApplicationWillResignActiveNotification object:nil]; with the corresponding in ViewDidUnload: [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil]; Does anyone have any suggestions? EDIT: - (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ NSString *identifier = segue.identifier; if ([identifier isEqualToString: @"Start Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=-1; gameWindow.delegate = self; } else if ([identifier isEqualToString: @"Resume Game"]){ gameWindow = (ViewController *)[segue destinationViewController]; gameWindow.newgame=0; gameWindow.delegate = self;

    Read the article

  • Using CreateFileMapping between to programs - C

    - by Jamie Keeling
    Hello, I have two window form applications written in C, one holds a struct consisting of two integers, another will receive it using the CreateFileMapping. Although not directly related I want to have three events in place so each of the processes can "speak" to each other, one saying that the first program has something to pass to the second, one saying the first one has closed and another saying the second one has closed. What would be the best way about doing this exactly? I've looked at the MSDN entry for the CreateFileMapping operation but I'm still not sure as to how it should be done. I didn't want to start implementing it without having some sort of clear idea as to what I need to do. Thanks for your time.

    Read the article

  • XMLHttpRequest leak

    - by Raja
    Hi everyone, Below is my javascript code snippet. Its not running as expected, please help me with this. <script type="text/javascript"> function getCurrentLocation() { console.log("inside location"); navigator.geolocation.getCurrentPosition(function(position) { insert_coord(new google.maps.LatLng(position.coords.latitude,position.coords.longitude)); }); } function insert_coord(loc) { var request = new XMLHttpRequest(); request.open("POST","start.php",true); request.onreadystatechange = function() { callback(request); }; request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); request.send("lat=" + encodeURIComponent(loc.lat()) + "&lng=" + encodeURIComponent(loc.lng())); return request; } function callback(req) { console.log("inside callback"); if(req.readyState == 4) if(req.status == 200) { document.getElementById("scratch").innerHTML = "callback success"; //window.setTimeout("getCurrentLocation()",5000); setTimeout(getCurrentLocation,5000); } } getCurrentLocation(); //called on body load </script> What i'm trying to achieve is to send my current location to the php page every 5 seconds or so. i can see few of the coordinates in my database but after sometime it gets weird. Firebug show very weird logs like simultaneous POST's at irregular intervals. Here's the firebug screenshot: IS there a leak in the program. please help. EDIT: The expected outcome in the firebug console should be like this :- inside location POST .... inside callback /* 5 secs later */ inside location POST ... inside callback /* keep repeating */

    Read the article

  • Understanding C++ pointers (when they point to a pointer)

    - by Stephano
    I think I understand references and pointers pretty well. Here is what I (think I) know: int i = 5; //i is a primitive type, the value is 5, i do not know the address. int *ptr; //a pointer to an int. i have no way if knowing the value yet. ptr = &i; //now i have an address for the value of i (called ptr) *ptr = 10; //go get the value stored at ptr and change it to 10 Please feel free to comment or correct these statements. Now I'm trying to make the jump to arrays of pointers. Here is what I do not know: char **char_ptrs = new char *[50]; Node **node_ptrs = new Node *[50]; My understanding is that I have 2 arrays of pointers, one set of pointers to chars and one to nodes. So if I wanted to set the values, I would do something like this: char_ptrs[0] = new char[20]; node_ptrs[0] = new Node; Now I have a pointer, in the 0 position of my array, in each respective array. Again, feel free to comment here if I'm confused. So, what does the ** operator do? Likewise, what is putting a single * next to the instantiation doing (*[50])? (what is that called exactly, instantiation?)

    Read the article

  • Objective-C ref count and autorelease

    - by turbovince
    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 :100.0f]; // ref count goes to 3... why ? [myRect release]; [pool drain]; return 0; } Rectangle's origin is declared as a (retain) synthesized property. Just wondering 2 things: Why does ref count goes to 3 when using the getter accessor of Rectangle's origin? Am I doing something wrong ? With a ref count of 3, I don't understand how this snippet of code cannot leak. Calling release on myRect will make it go down to 2 since I call release on the origin in dealloc(). But then, when does autorelease take effect? Thanks!

    Read the article

  • Autorelease vs. Release

    - by Sheehan Alam
    Given the two scenarios, which code is best practice and why? Autorelease loginButton = [[[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStylePlain target:self action:@selector(loginButtonClicked:)] autorelease]; self.navigationItem.rightBarButtonItem = loginButton; or Release loginButton = [[UIBarButtonItem alloc] initWithTitle:@"Login" style:UIBarButtonItemStylePlain target:self action:@selector(loginButtonClicked:)]; self.navigationItem.rightBarButtonItem = loginButton; [loginButton release];

    Read the article

  • Compute jvm heap size to host web application

    - by Enrique
    Hello, I want to host a web application on a private JVM they offer 32, 64, 128, 256 MB plans. My web application uses Spring. And I store some objects for every logged in user session. My question is: How can I profile my web app to see how much heap size it needs so I can choose a plan?, How can I simulate hundreds of users logged in at the same time? I'm developing the application using Netbeans 6.7 Java 1.6 Tomcat 6.0.18 Thank you.

    Read the article

  • How to relink existing shared library with extra object file

    - by awy
    I have existing Linux shared object file (shared library) which has been stripped. I want to produce a new version of the library with some additional functions included. I had hoped that something like the following would work, but does not: ld -o newlib.so newfuncs.o --whole-archive existinglib.so I do not have the source to the existing library. I could get it but getting a full build environment with the necessary dependencies in place would be a lot of effort for what seems like a simple problem.

    Read the article

  • Leaks in passing the request using URL at NSString, Objective-C.

    - by Madan Mohan
    Hi Guys, I getting the leak in this method even the allocated nsstring is released. -(BOOL)getTicket:(NSString*)userName passWord:(NSString*)aPassword isLogin:(BOOL)isLogin { login =[self getloginList]; username = login.name; password = login.password; NSString* str=@""; if (isLogin == YES) { str = @"https://accounts.=true&LOGIN_ID="; str = [str stringByAppendingString:[self _encodeString:username]]; str = [str stringByAppendingString:@"&PASSWORD="]; str = [str stringByAppendingString:[self _encodeString:password]]; } else if (isLogin == NO) { str = @"https://accounts.=true&LOGIN_ID="; str = [str stringByAppendingString:[self _encodeString:userName]]; str = [str stringByAppendingString:@"&PASSWORD="]; str = [str stringByAppendingString: [self _encodeString:aPassword]]; } NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:25.0]; [request setHTTPMethod: @"POST"]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];//****************** i am getting leak here showing as nsstring is leaking NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; printf("\n returnString in getticket:%s",[returnString UTF8String]); NSRange textRange; textRange =[returnString rangeOfString:@"TICKET"]; if(textRange.location != NSNotFound) { printf("\n **********************"); NSArray* splitValues = [returnString componentsSeparatedByString:@"TICKET="]; NSString* str1 = [splitValues objectAtIndex:1]; NSArray* splitValues1 = [str1 componentsSeparatedByString:@"RESULT"]; NSString* ticket1 = [splitValues1 objectAtIndex:0]; self.ticket = ticket1; self.isCorrectLogin = YES; [returnString release]; return YES; } else { self.isCorrectLogin = NO; [returnString release]; return NO; } return NO; } Please help me out of this problem.

    Read the article

  • overloading new/delete problem

    - by hidayat
    This is my scenario, Im trying to overload new and delete globally. I have written my allocator class in a file called allocator.h. And what I am trying to achieve is that if a file is including this header file, my version of new and delete should be used. So in a header file "allocator.h" i have declared the two functions extern void* operator new(std::size_t size); extern void operator delete(void *p, std::size_t size); I the same header file I have a class that does all the allocator stuff, class SmallObjAllocator { ... }; I want to call this class from the new and delete functions and I would like the class to be static, so I have done this: template<unsigned dummy> struct My_SmallObjectAllocatorImpl { static SmallObjAllocator myAlloc; }; template<unsigned dummy> SmallObjAllocator My_SmallObjectAllocatorImpl<dummy>::myAlloc(DEFAULT_CHUNK_SIZE, MAX_OBJ_SIZE); typedef My_SmallObjectAllocatorImpl<0> My_SmallObjectAllocator; and in the cpp file it looks like this: allocator.cc void* operator new(std::size_t size) { std::cout << "using my new" << std::endl; if(size > MAX_OBJ_SIZE) return malloc(size); else return My_SmallObjectAllocator::myAlloc.allocate(size); } void operator delete(void *p, std::size_t size) { if(size > MAX_OBJ_SIZE) free(p); else My_SmallObjectAllocator::myAlloc.deallocate(p, size); } The problem is when I try to call the constructor for the class SmallObjAllocator which is a static object. For some reason the compiler are calling my overloaded function new when initializing it. So it then tries to use My_SmallObjectAllocator::myAlloc.deallocate(p, size); which is not defined so the program crashes. So why are the compiler calling new when I define a static object? and how can I solve it?

    Read the article

  • How do i free objects in C#

    - by assassin
    Hi, Can anyone please tell me how I can free objects in C#? For example, I have an object: Object obj1 = new Object(); //Some code using obj1 //Here I would like to free obj1, after it is no longer required and also more importantly its scope is the full run time of the program. Thanks for all your help

    Read the article

  • Set asisde space for ADT when reading integers from file

    - by That Guy
    I'm using C to make maze solver. The program should be able read a maze from a text file containing a grid of 1 and 0 representing walls and paths. This file could be of any size as the user selects which maze to use. The program should then show the maze being solved. As the maze is being solved it should show where has been walked and how many steps have been taken. I have made an ADT called Cell containing a bool for wall or path and an integer for steps taken. I now need to populate a 2D array of Cells which means I need to set aside enough space to store a Cell for every integer in the maze file. What would be the best way to do this?

    Read the article

  • C instruction address

    - by aaa
    hello. Disclaimer, I not do anything in particular with regards this question, just curious. Is it possible to take address of instruction or block in C? in essence, is there jump equivalent in C? for example: void function() { int k; { // is a possible to go to this address from arbitrary point in code? int i, j; k += j+i; } } thank you

    Read the article

< Previous Page | 136 137 138 139 140 141 142 143 144 145 146 147  | Next Page >