Search Results

Search found 867 results on 35 pages for 'leak'.

Page 5/35 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Adobe Reader 9.0 memory leak while loading-unloading PDF files every one second indefinitely

    - by Total Starnger
    I have c++ written MFC based application that has PDF object viewer as a part of the implementation. A whole thing works just fine with Adobe Reader 8.0. Once I switched to Adobe Reader 9.0 as a default PDF reader, I keep experiencing small memory leak that forces my application to crash within a half an hour of continuous loading-unloading different PDF files. Any ideas what might cause this memory leak and is there any cure besides replacing Adobe Reader 9.0 with anything else? (Works fine with Foxit PDF reader as well, by the way..)

    Read the article

  • MPMediaickerController memory leak identified by Leaks instrument

    - by Joe
    This is code from Apple's Addmusic example. MPMediaPickerController *picker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeMusic]; picker.delegate = self; picker.allowsPickingMultipleItems = YES; picker.prompt = NSLocalizedString (@"Add songs to play", "Prompt in media item picker"); // The media item picker uses the default UI style, so it needs a default-style // status bar to match it visually [[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault animated: YES]; [self presentModalViewController: picker animated: YES]; [picker release]; I'm using this code in my app and the Leaks instrument highlights a leak on the line: [self presentModalViewController: picker animated: YES]; I think that this is because this line retains a reference to picker which cannot be subsequently released. Is there any way around this or is Leaks incorrectly identifying a leak?

    Read the article

  • Iphone memory leak with malloc

    - by Icky
    Hello. I have memory leak, found by instruments and it is supposed to be in this line of code: indices = malloc( sizeof(indices[0]) * totalQuads * 6); This is actually a code snippet from a tutorial, something which i think is leak-free so to say. Now I reckon, the error is somewhere else, but I do not know, where. These are the last trackbacks: 5 ColorRun -[EAGLView initWithCoder:] /Users/thomaskopinski/programming/colorrun_3.26/Classes/EAGLView.m:98 4 ColorRun -[EAGLView initGame] /Users/thomaskopinski/programming/colorrun_3.26/Classes/EAGLView.m:201 3 ColorRun -[SpriteSheet initWithImageNamed:spriteWidth:spriteHeight:spacing:imageScale:] /Users/thomaskopinski/programming/colorrun_3.26/SpriteSheet.m:68 2 ColorRun -[Image initWithImage:scale:] /Users/thomaskopinski/programming/colorrun_3.26/Image.m:122 1 ColorRun -[Image initImpl] /Users/thomaskopinski/programming/colorrun_3.26/Image.m:158 0 libSystem.B.dylib malloc Does anyone know how to approach this?

    Read the article

  • Can C++ memory leaks negatively affect CPU usage?

    - by Dan
    Hi all, I have a C++ program that has a pretty terrible memory leak, about 4MB / second. I know where it's coming from and can fix it, but that's not my main problem. My program is taking up a very large amount of CPU usage and it isn't running as fast as I want it to. I have two different threads in the program. One by itself takes ~50% CPU, which is fine, and the other by itself takes ~15% CPU, which is fine. Together however CPU usage is 100% and the program cannot run as fast as it needs to. Can a memory leak by itself cause a problem like this? I know the program will eventually crash due to the leaked memory, but does a memory leak immediately lead to a slower program? By immediately I mean the program is too slow at the very start, not just when the memory footprint is huge. Thanks!

    Read the article

  • How i solve memory leak problem?

    - by RRB
    Hi, I developing an simple application in which design or make code in which i creating and instance object of UIImage. When i swip on Ipad screen it make up an image of the sreen and that image i render into UIImage object after that this image i set into UIImageView object and UIimage object is released. Every time i swipe on the screen and above process is does again and again. But it give me leak in renderImage = [[UIImage alloc] init];. Code, _renderImage = [[UIImage alloc] init]; _textImageV = [[UIImageView alloc] init]; [self renderIntoImage]; -(void)renderIntoImage { UIGraphicsBeginImageContext(bgTableView.bounds.size); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; _renderImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); } _textImageV.image = _renderImage; [_renderImage release]; after completing the process of swipe i also releasing _textImageV. How i solve the memory leak problem in UIImage *_renderImage?

    Read the article

  • Constant Memory Leak in SpeechSynthesizer

    - by DudeFX
    I have developed a project which I would like to release which uses c#, WPF and the System.Speech.Synthesizer object. The issue preventing the release of this project is that whenever SpeakAsync is called it leaves a memory leak that grows to the point of eventual failure. I believe I have cleaned up properly after using this object, but cannot find a cure. I have run the program through Ants Memory Profiler and it reports that WAVEHDR and WaveHeader is growing with each call. I have created a sample project to try to pinpoint the cause, but am still at a loss. Any help would be appreciated. The project uses VS2008 and is a c# WPF project that targets .NET 3.5 and Any CPU. You need to manually add a reference to System.Speech. Here is the Code: <Window x:Class="SpeechTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Grid> <StackPanel Orientation="Vertical"> <Button Content="Start Speaking" Click="Start_Click" Margin="10" /> <Button Content="Stop Speaking" Click="Stop_Click" Margin="10" /> <Button Content="Exit" Click="Exit_Click" Margin="10"/> </StackPanel> </Grid> // Start of code behind using System; using System.Windows; using System.Speech.Synthesis; namespace SpeechTest { public partial class Window1 : Window { // speak setting private bool speakingOn = false; private int curLine = 0; private string [] speakLines = { "I am wondering", "Why whenever Speech is called", "A memory leak occurs", "If you run this long enough", "It will eventually crash", "Any help would be appreciated" }; public Window1() { InitializeComponent(); } private void Start_Click(object sender, RoutedEventArgs e) { speakingOn = true; SpeakLine(); } private void Stop_Click(object sender, RoutedEventArgs e) { speakingOn = false; } private void Exit_Click(object sender, RoutedEventArgs e) { App.Current.Shutdown(); } private void SpeakLine() { if (speakingOn) { // Create our speak object SpeechSynthesizer spk = new SpeechSynthesizer(); spk.SpeakCompleted += new EventHandler(spk_Completed); // Speak the line spk.SpeakAsync(speakLines[curLine]); } } public void spk_Completed(object sender, SpeakCompletedEventArgs e) { if (sender is SpeechSynthesizer) { // get access to our Speech object SpeechSynthesizer spk = (SpeechSynthesizer)sender; // Clean up after speaking (thinking the event handler is causing the memory leak) spk.SpeakCompleted -= new EventHandler(spk_Completed); // Dispose the speech object spk.Dispose(); // bump it curLine++; // check validity if (curLine = speakLines.Length) { // back to the beginning curLine = 0; } // Speak line SpeakLine(); } } } } I run this program on Windows 7 64 bit and it will run and eventually halt when attempting to create a new SpeechSynthesizer object. When run on Windows Vista 64 bit the memory will grow from a starting point of 34k to so far about 400k and growing. Can anyone see anything in the code that might be causing this, or is this an issue with the Speech object itself. Any help would be appreciated.

    Read the article

  • OpenCV Mat creation memory leak

    - by Royi Freifeld
    My memory is getting full fairly quick once using the next piece of code. Valgrind shows a memory leak, but everything is allocated on stack and (supposed to be) freed once the function ends. void mult_run_time(int rows, int cols) { Mat matrix(rows,cols,CV_32SC1); Mat row_vec(cols,1,CV_32SC1); /* initialize vector and matrix */ for (int col = 0; col < cols; ++col) { for (int row = 0; row < rows; ++row) { matrix.at<unsigned long>(row,col) = rand() % ULONG_MAX; } row_vec.at<unsigned long>(1,col) = rand() % ULONG_MAX; } /* end initialization of vector and matrix*/ matrix*row_vec; } int main() { for (int row = 0; row < 20; ++row) { for (int col = 0; col < 20; ++col) { mult_run_time(row,col); } } return 0; } Valgrind shows that there is a memory leak in line Mat row_vec(cols,1,CV_32CS1): ==9201== 24,320 bytes in 380 blocks are definitely lost in loss record 50 of 50 ==9201== at 0x4026864: malloc (vg_replace_malloc.c:236) ==9201== by 0x40C0A8B: cv::fastMalloc(unsigned int) (in /usr/local/lib/libopencv_core.so.2.3.1) ==9201== by 0x41914E3: cv::Mat::create(int, int const*, int) (in /usr/local/lib/libopencv_core.so.2.3.1) ==9201== by 0x8048BE4: cv::Mat::create(int, int, int) (mat.hpp:368) ==9201== by 0x8048B2A: cv::Mat::Mat(int, int, int) (mat.hpp:68) ==9201== by 0x80488B0: mult_run_time(int, int) (mat_by_vec_mult.cpp:26) ==9201== by 0x80489F5: main (mat_by_vec_mult.cpp:59) Is it a known bug in OpenCV or am I missing something?

    Read the article

  • Sqlite Database LEAK FOUND exception in android?

    - by androidbase
    hi all, i am getting this exception in database Leak Found my LOGCAT Shows this: 02-17 17:20:37.857: INFO/ActivityManager(58): Starting activity: Intent { cmp=com.example.brown/.Bru_Bears_Womens_View (has extras) } 02-17 17:20:38.477: DEBUG/dalvikvm(434): GC freed 1086 objects / 63888 bytes in 119ms 02-17 17:20:38.556: ERROR/Database(434): Leak found 02-17 17:20:38.556: ERROR/Database(434): java.lang.IllegalStateException: /data/data/com.example.brown/databases/BRUNEWS_DB_01.db SQLiteDatabase created and never closed 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.<init>(SQLiteDatabase.java:1694) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:738) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:760) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:753) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ApplicationContext.openOrCreateDatabase(ApplicationContext.java:473) 02-17 17:20:38.556: ERROR/Database(434): at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:193) 02-17 17:20:38.556: ERROR/Database(434): at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:98) 02-17 17:20:38.556: ERROR/Database(434): at com.example.brown.Brown_Splash.onCreate(Brown_Splash.java:52) 02-17 17:20:38.556: ERROR/Database(434): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 02-17 17:20:38.556: ERROR/Database(434): at android.os.Handler.dispatchMessage(Handler.java:99) 02-17 17:20:38.556: ERROR/Database(434): at android.os.Looper.loop(Looper.java:123) 02-17 17:20:38.556: ERROR/Database(434): at android.app.ActivityThread.main(ActivityThread.java:4363) 02-17 17:20:38.556: ERROR/Database(434): at java.lang.reflect.Method.invokeNative(Native Method) 02-17 17:20:38.556: ERROR/Database(434): at java.lang.reflect.Method.invoke(Method.java:521) 02-17 17:20:38.556: ERROR/Database(434): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 02-17 17:20:38.556: ERROR/Database(434): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 02-17 17:20:38.556: ERROR/Database(434): at dalvik.system.NativeStart.main(Native Method) how can i solve it??? thanks in advance...

    Read the article

  • UIAlertView -show causing a memory leak

    - by Erik
    I'm relatively new to iPhone Development, so this may be my fault, but it goes against what I've seen. :) I think that I'm creating a UIAlertView that lives just in this vaccuum of the 'if' statement. NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if(!data) { // Add an alert UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Unable to contact server" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; NSLog(@"retain count before show: %i", alert.retainCount); [alert show]; NSLog(@"retain count before release: %i", alert.retainCount); [alert release]; NSLog(@"retain count after release: %i", alert.retainCount); return nil; } However, the console logs baffle me. retain count before show: 1 retain count before release: 6 retain count after release: 5 I've tried also adding: alert = nil; after the release. That makes the retain count 0, but I still show a leak. And if it helps, the leak's Responsible Frame is UIKeyboardInputManagerClassForInputMode. I'm also using OS 4 Beta 3. So anyone have any ideas how a local UIAlertView's retain count would increment itself by 5 when calling -show? Thanks for your help!

    Read the article

  • [Cocoa] Can't find leak in my code.

    - by ryyst
    Hi, I've been spending the last few hours trying to find the memory leak in my code. Here it is: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; expression = [expression stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; // expression is an NSString object. NSArray *arguments = [NSArray arrayWithObjects:expression, [@"~/Desktop/file.txt" stringByExpandingTildeInPath], @"-n", @"--line-number", nil]; NSPipe *outPipe = [[NSPipe alloc] init]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/bin/grep"]; [task setArguments:arguments]; [task setStandardOutput:outPipe]; [outPipe release]; [task launch]; NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile]; [task waitUntilExit]; [task release]; NSString *string = [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding]; string = [string stringByReplacingOccurrencesOfString:@"\r" withString:@""]; int linesNum = 0; NSMutableArray *possibleMatches = [[NSMutableArray alloc] init]; if ([string length] > 0) { NSArray *lines = [string componentsSeparatedByString:@"\n"]; linesNum = [lines count]; for (int i = 0; i < [lines count]; i++) { NSString *currentLine = [lines objectAtIndex:i]; NSArray *values = [currentLine componentsSeparatedByString:@"\t"]; if ([values count] == 20) [possibleMatches addObject:currentLine]; } } [string release]; [pool release]; return [possibleMatches autorelease]; I tried to follow the few basic rules of Cocoa memory management, but somehow there still seems to be a leak, I believe it's an array that's leaking. It's noticeable if possibleMatches is large. You can try the code by using any large file as "~/Desktop/file.txt" and as expression something that yields many results when grep-ing. What's the mistake I'm making? Thanks for any help! -- Ry

    Read the article

  • Memory leak at Autorelease pool in Iphone sdk

    - by monish
    Hi guys, I am getting leak at [pool release]; My code here is: #pragma mark UISearchBarDelegate delegate methods - (void)performSearch:(UISearchBar *)aSearchBar { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; artistName= [aSearchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if ([artistName length] > 0) { [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; LyricsAppDelegate* appDelegate = (LyricsAppDelegate*) [ [UIApplication sharedApplication] delegate]; artistsList=[appDelegate doSearch:artistName ]; [theTableView reloadData]; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; [aSearchBar resignFirstResponder]; } else { [aSearchBar resignFirstResponder]; } [NSThread exit]; [pool release]; } - (void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar { @try { [NSThread detachNewThreadSelector:@selector(performSearch:) toTarget:self withObject:aSearchBar]; [aSearchBar resignFirstResponder]; } @catch (NSException * e) { NSLog(@"\n caught an exception"); } @finally { } } Here I am getting leak at [pool release]; in performSearch method. How can I solve this. Anyone's help will be much appreciated. Thank you, Monish.

    Read the article

  • G++ Multi-platform memory leak detection tool

    - by indyK1ng
    Does anyone know where I can find a memory memory leak detection tool for C++ which can be either run in a command line or as an Eclipse plug-in in Windows and Linux. I would like it to be easy to use. Preferably one that doesn't overwrite new(), delete(), malloc() or free(). Something like GDB if its gonna be in the command line, but I don't remember that being used for detecting memory leaks. If there is a unit testing framework which does this automatically, that would be great. This question is similar to other questions (such as http://stackoverflow.com/questions/283726/memory-leak-detection-under-windows-for-gnu-c-c ) however I feel it is different because those ask for windows specific solutions or have solutions which I would rather avoid. I feel I am looking for something a bit more specific here. Suggestions don't have to fulfill all requirements, but as many as possible would be nice. Thanks. EDIT: Since this has come up, by "overwrite" I mean anything which requires me to #include a library or which otherwise changes how C++ compiles my code, if it does this at run time so that running the code in a different environment won't affect anything that would be great. Also, unfortunately, I don't have a Mac, so any suggestions for that are unhelpful, but thank you for trying. My desktop runs Windows (I have Linux installed but my dual monitors don't work with it) and I'd rather not run Linux in a VM, although that is certainly an option. My laptop runs Linux, so I can use that tool on there, although I would definitely prefer sticking to my desktop as the screen space is excellent for keeping all of the design documentation and requirements in view without having to move too much around on the desktop. NOTE: While I may try answers, I won't mark one as accepted until I have tried the suggestion and it is satisfactory. EDIT2: I'm not worried about the cross-platform compatibility of my code, it's a command line application using just the C++ libraries.

    Read the article

  • C++ casted realloc causing memory leak

    - by wyatt
    I'm using a function I found here to save a webpage to memory with cURL: struct WebpageData { char *pageData; size_t size; }; size_t storePage(void *input, size_t size, size_t nmemb, void *output) { size_t realsize = size * nmemb; struct WebpageData *page = (struct WebpageData *)output; page->pageData = (char *)realloc(page->pageData, page->size + realsize + 1); if(page->pageData) { memcpy(&(page->pageData[page->size]), input, realsize); page->size += realsize; page->pageData[page->size] = 0; } return realsize; } and find the line: page->pageData = (char *)realloc(page->pageData, page->size + realsize + 1); is causing a memory leak of a few hundred bytes per call. The only real change I've made from the original source is casting the line in question to a (char *), which my compiler (gcc, g++ specifically if it's a c/c++ issue, but gcc also wouldn't compile with the uncast statement) insisted upon, but I assume this is the source of the leak. Can anyone elucidate? Thanks

    Read the article

  • Gradual memory leak and slowdown in loop

    - by Benji XVI
    I have a simple foundation tool that exports every frame of a movie as a .tiff file. Here is the relevant code: NSString* movieLoc = [NSString stringWithCString:argv[1]]; QTMovie *sourceMovie = [QTMovie movieWithFile:movieLoc error:nil]; int i=0; while (QTTimeCompare([sourceMovie currentTime], [sourceMovie duration]) != NSOrderedSame) { // save image of movie to disk NSAutoreleasePool *arp = [[NSAutoreleasePool alloc] init]; NSString *filePath = [NSString stringWithFormat:@"/somelocation_%d.tiff", i++]; NSData *currentImageData = [[sourceMovie currentFrameImage] TIFFRepresentation]; [currentImageData writeToFile:filePath atomically:NO]; NSLog(@"%@", filePath); [sourceMovie stepForward]; [arp release]; } [pool drain]; return 0; As you can see, in order to prevent very large memory buildups with the various transparently-autoreleased variables in the loop, we create, and flush, an autoreleasepool with every run through the loop. However, over the course of stepping through a movie, the amount of memory used by the program still gradually increases, and the speed at which frames are processed drops precipitously. (From ~0.5 seconds per frame at the start, to ~2 seconds per frame by the 250th frame.) The only thing I can think can be causing the gradual memory leak is a buildup of the NSAutoreleasePool objects themselves. Am I right in thinking they will only be deallocated when the outer pool is released? If so, is there a better memory management solution here? Creating a pool every run through the loop seems a little hacky. And if not, what is causing the slow memory leak? (It is not NSStrings, and much too slow to be NSImages or NSDatas.) And what could be causing the slowdown?

    Read the article

  • Surprising IPhone leak

    - by Ethan
    Hey guys, So I'm running instruments on my app, and getting a leak that I could have sworn I was doing right. + (NSMutableArray *)decode:(NSDictionary *)encoded_faculty_array { NSArray *faculty_id_data = [encoded_faculty_array objectForKey:@"faculty_id"]; NSArray *faculty_first_name = [encoded_faculty_array objectForKey:@"first_name"]; NSArray *faculty_last_name = [encoded_faculty_array objectForKey:@"last_name"]; NSMutableArray* faculty_array = [[NSMutableArray alloc] init]; for(int a = 0; a < [faculty_id_data count]; a++) { Faculty *new_fac = [[Faculty alloc] initWithFacultyId:[Dearray clean:[faculty_id_data objectAtIndex:a] withDefault:@"0"] andFirstName:[Dearray clean:[faculty_first_name objectAtIndex:a] withDefault:@"Name not found"] andLastName:[Dearray clean:[faculty_last_name objectAtIndex:a] withDefault:@" "] andBio:nil andDegrees:nil andTitle:nil]; [faculty_array addObject:new_fac]; [new_fac release]; } [faculty_array autorelease]; return faculty_array; } It's reporting a leak on new_fac. I released it immediately after I called it though. Any idea what could be causing that problem? Thanks.

    Read the article

  • HashMap Memory Leak because of Dynamic Array

    - by Jake M
    I am attempting to create my own HashMap to understand how they work. I am using an array of Linked Lists to store the values(strings) in my hashmap. I am creating the array like this: Node** list; Instead of this: Node* list[nSize]; This is so the array can be any size at runtime. But I think I am getting a memory leak because of how I am doing this. I dont know where the error is but when I run the following simple code the .exe crashes. Why is my application crashing and how can I fix it? Note: I am aware that using a vector would be much better than an array but this is just for learning and I want to challenge myself to create the hashmap using a 'Dynamic' Array. PS: is that the correct term(Dynamic Array) for the kind of array I am using? struct Node { // to implement }; class HashMap { public: HashMap(int dynSize) { *list = new Node[dynSize]; size = dynSize; for (int i=0; i<size; i++) list[i] = NULL; cout << "END\n"; } ~HashMap() { for (int i=0; i<size; i++) delete list[i]; } private: Node** list; // I could use a vector here but I am experimenting with a pointer to an array(pointer), also its more elegant int size; }; int main() { // When I run this application it crashes. Where is my memory leak? HashMap h(5); system("PAUSE"); return 0; }

    Read the article

  • MDI WinForm application and duplicate child form memory leak

    - by Steve
    This is a WinForm MDI application problem (.net framework 3.0). It will be described in C#. Sorry it is a bit long because I try to make things as clear as possible. I have a MDI application. At some point I find that one MDI child form is never released. There is a menu that creates the MDI child form and show it. When the MDI child form is closed, it is supposed to be destroyed and the memory taken by it should be given back to .net. But to my surprise, this is not true. All the MDI child form instances are kept in memory. This is obviously a "memory leak". Well, it is not a real leak in .net. It is just that I think the closed form should be dead but somehow there is at least one unknown reference from outside world that still connect with the closed form. I read some articles on the Web. Some says that when the MDI child form is closing, I should unwire all the event handlers, otherwise some event handlers may keep my form alive. Some says that DataBindings should be cleaned before the form is closing otherwise the DataBindings will add references to some global Hashtable and thus keep my form alive. My form contains quite a lot things. Many event handlers and many DataBindings and many BindingSources and few suspected controls containing user control and HelpProvider. I create a big method that unwires all the event handlers from all the relevant controls, clear all the DataBindings and DataSources. The HelpProvider and user controls are disposed carefully. At the end, I find that, I don't have to clear DataBindings and DataSources. Event handlers are definitely causing the problem. And MDI form structure also contributes to something. During my experiments, I find that, if you create a MDI child form, even if you close it, there will still be one instance in the memory. The reference is from PropertyStore of the main form. This means, unless the main form is closed (application ends), there will always be one instance of MDI child form in the memory. The good news is that, no matter how many times you open and close the child form, there will be only one instance, not a big "leak". When it comes to event handlers, things become more tricky. I have to address that, all the event handlers on my form are anonymous event handlers. Here is an example code: //On MDI child form's design code... Button btnSave = new Button(); btnSave.Click += new System.EventHandler(btnSave_Click); Where btnSave_Click is also a method in MDI child form. The above is always the case for various controls and various types of event. To me, this is a bi-directional circular reference. btnSave keeps a reference of MDI child form via the event handler. MDI child form keeps a reference of btnSave instance. To me again, such bi-directional circular reference should not cause any problem for .net's garbage collector. This means that I do not have to explicitly unwire the event when the form is being disposed: btnSave.Click -= btnSave_Click; But the truth is not so. For some event handlers, they are safe. Ignoring them do not cause any duplicate instance. For some other event handlers, they will cause one instance remaining in the memory (similar effect as the MDI form structure, but this time caused by the hanging event handlers). For some other event handlers, they will cause every instance opened in the memory. I am totally confused about the differences between these three types of event handlers. The controls are created in the same way and the event is attached in the same way. What is the difference? (Don't tell me it is the event handle methods that make difference.) Anyone has experience of this wired scenario and has an answer for me? Thanks a lot. So now, for safety issue, I will have to unwire all the event handlers when the form is being disposed. That will be a long list of similar code for each control. Is there a general way of removing events from controls in recursive way using reflection? What about performance issue? That's the end of my story and I am still in the middle of my problem. For any help, I thank you.

    Read the article

  • How to solve QPixmap::fromImage memory leak?

    - by dodoent
    Hello everyone! I have a problem with Qt. Here is a part of code that troubles me: void FullScreenImage::QImageIplImageCvt(IplImage *input) { help=cvCreateImage(cvGetSize(input), input->depth, input->nChannels); cvCvtColor(input, help, CV_BGR2RGB); QImage tmp((uchar *)help->imageData, help->width, help->height, help->widthStep, QImage::Format_RGB888); this->setPixmap(QPixmap::fromImage(tmp).scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); cvReleaseImage(&help); } void FullScreenImage::hideOnScreen() { this->hide(); this->clear(); } void FullScreenImage::showOnScreen(IplImage *slika, int delay) { QImageIplImageCvt(slika); this->showFullScreen(); if(delay>0) QTimer::singleShot(delay*1000, this, SLOT(hideOnScreen())); } So, the method showOnScreen uses private method QImageIplImageCvt to create QImage from IplImage (which is used by the openCV), which is then used to create QPixmap in order to show the image in full screen. FullScreenImage class inherits QLabel. After some delay, the fullscreen picture should be hidden, so I use QTimer to trigger an event after some delay. The event handler is the hideOnScreen method which hides the label and should clear the memory. The problem is the following: Whenever I call QPixmap::fromImage, it allocates the memory for the pixmap data and copies the data from QImage memory buffer to the QPixmap memory buffer. After the label is hidden, the QPixmap data still remains allocated, and even worse, after the new QPixmap::fromImage call the new chunk of memory is allocated for the new picture, and the old data is not freed from memory. This causes a memory leak (cca 10 MB per method call with my testing pictures). How can I solve that leak? I've even tried to create a private QPixmap variable, store pixmap created by the QPixmap::fromImage to it, and then tried to call its destructor in hideOnScreen method, but it didn't help. Is there a non-static way to create QPixmap from QImage? Or even better, is there a way to create QPixmap directly from IplImage* ? Thank you in advance for your answers.

    Read the article

  • Python Memory leak - Solved, but still puzzled

    - by disappearedng
    Dear everyone, I have successfully debugged my own memory leak problems. However, I have noticed some very strange occurence. for fid, fv in freqDic.iteritems(): outf.write(fid+"\t") #ID for i, term in enumerate(domain): #Vector tfidf = self.tf(term, fv) * self.idf( term, docFreqDic) if i == len(domain) - 1: outf.write("%f\n" % tfidf) else: outf.write("%f\t" % tfidf) outf.flush() print "Memory increased by", int(self.memory_mon.usage()) - startMemory outf.close() def tf(self, term, freqVector): total = freqVector[TOTAL] if total == 0: return 0 if term not in freqVector: ## When you don't have these lines memory leaks occurs return 0 ## return float(freqVector[term]) / freqVector[TOTAL] def idf(self, term, docFrequencyPerTerm): if term not in docFrequencyPerTerm: return 0 return math.log( float(docFrequencyPerTerm[TOTAL])/docFrequencyPerTerm[term]) Basically let me describe my problem: 1) I am doing tfidf calculations 2) I traced that the source of memory leaks is coming from defaultdict. 3) I am using the memory_mon from http://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python 4) The reason for my memory leaks is as follows: a) in self.tf, if the lines: if term not in freqVector: return 0 are not added that will cause the memory leak. (I verified this myself using memory_mon and noticed a sharp increase in memory that kept on increasing) The solution to my problem was 1) since fv is a defaultdict, any reference to it that are not found in fv will create an entry. Over a very large domain, this will cause memory leaks. I decided to use dict instead of default dict and the memory problem did go away. My only puzzle is: since fv is created in "for fid, fv in freqDic.iteritems():" shouldn't fv be destroyed at the end of every for loop? I tried putting gc.collect() at the end of the for loop but gc was not able to collect everything (returns 0). Yes, the hypothesis is right, but the memory should stay fairly consistent with ever for loop if for loops do destroy all temp variables. This is what it looks like with that two line in self.tf: Memory increased by 12 Memory increased by 948 Memory increased by 28 Memory increased by 36 Memory increased by 36 Memory increased by 32 Memory increased by 28 Memory increased by 32 Memory increased by 32 Memory increased by 32 Memory increased by 40 Memory increased by 32 Memory increased by 32 Memory increased by 28 and without the the two line: Memory increased by 1652 Memory increased by 3576 Memory increased by 4220 Memory increased by 5760 Memory increased by 7296 Memory increased by 8840 Memory increased by 10456 Memory increased by 12824 Memory increased by 13460 Memory increased by 15000 Memory increased by 17448 Memory increased by 18084 Memory increased by 19628 Memory increased by 22080 Memory increased by 22708 Memory increased by 24248 Memory increased by 26704 Memory increased by 27332 Memory increased by 28864 Memory increased by 30404 Memory increased by 32856 Memory increased by 33552 Memory increased by 35024 Memory increased by 36564 Memory increased by 39016 Memory increased by 39924 Memory increased by 42104 Memory increased by 42724 Memory increased by 44268 Memory increased by 46720 Memory increased by 47352 Memory increased by 48952 Memory increased by 50428 Memory increased by 51964 Memory increased by 53508 Memory increased by 55960 Memory increased by 56584 Memory increased by 58404 Memory increased by 59668 Memory increased by 61208 Memory increased by 62744 Memory increased by 64400 I look forward to your answer

    Read the article

  • COM C# Memory leak Tracing

    - by maxfridbe
    Is there a way to find out the memory usage of each dll within a c# application using com dll's? Or what would you say is the best way to find out why memory grows exponentially when using a com object (IE. Whether the COM object has a memory leak, or whether some special freeing up of objects passed to managed code has to occur(and/or how to do that)).

    Read the article

  • Java / Tomcat memory leak in RedHat Linux?

    - by black-rocky
    Hi, I've got a Red Hat box with 6G memory running Tomcat and I'm trying to figure out how much memory I have left on the box. Problem is, top & jconsole is showing one figure (around 200M), and system monitor is showing a different figure (around 2G). Does anybody know what the difference is? I'm not sure if there is a memory leak happenning here, but the highest memory consumer is a tomcat process that's taking 2.2G of memory. Screenshots below:

    Read the article

  • AS3 Memory Leak Example

    - by Skawful
    Can someone post an example of as3 code (specifically event listener included) that would be a simple example of something that could leak memory... also hopefully could you post a solution to the problem shown? The question is: What is a simple example of leaking memory in an AS3 event listener and how can you solve it?

    Read the article

  • UIImageWriteToSavedPhotosAlbum showing memory leak with iPhone connected to Instruments

    - by user168739
    Hi, I'm using version 3.0.1 of the SDK. With the iPhone connected to Instruments I'm getting a memory leak when I call UIImageWriteToSavedPhotosAlbum. Below is my code: NSString *gnTmpStr = [NSString stringWithFormat:@"%d", count]; UIImage *ganTmpImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:gnTmpStr ofType:@"jpg"]]; // Request to save the image to camera roll UIImageWriteToSavedPhotosAlbum(ganTmpImage, self, @selector(imageSavedToPhotosAlbum:didFinishSavingWithError:contextInfo:), nil); and the selector method - (void)imageSavedToPhotosAlbum:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { NSString *message; NSString *title; if (!error) { title = @"Wallpaper"; message = @"Wallpaper Saved"; } else { title = @"Error"; message = [error description]; } UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } Am I forgetting to release something once the image has been saved and the selector method imageSavedToPhotosAlbum is called? Or is there a possible known issue with UIImageWriteToSavedPhotosAlbum? Here is the stack trace from Instruments: Leaked Object: GeneralBlock-3584 size: 3.50 KB 30 MyApp start 29 MyApp main /Users/user/Desktop/MyApp/main.m:14 28 UIKit UIApplicationMain 27 UIKit -[UIApplication _run] 26 GraphicsServices GSEventRunModal 25 CoreFoundation CFRunLoopRunInMode 24 CoreFoundation CFRunLoopRunSpecific 23 GraphicsServices PurpleEventCallback 22 UIKit _UIApplicationHandleEvent 21 UIKit -[UIApplication sendEvent:] 20 UIKit -[UIWindow sendEvent:] 19 UIKit -[UIWindow _sendTouchesForEvent:] 18 UIKit -[UIControl touchesEnded:withEvent:] 17 UIKit -[UIControl(Internal) _sendActionsForEvents:withEvent:] 16 UIKit -[UIControl sendAction:to:forEvent:] 15 UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] 14 UIKit -[UIApplication sendAction:to:from:forEvent:] 13 CoreFoundation -[NSObject performSelector:withObject:withObject:] 12 UIKit -[UIBarButtonItem(Internal) _sendAction:withEvent:] 11 UIKit -[UIApplication sendAction:to:from:forEvent:] 10 CoreFoundation -[NSObject performSelector:withObject:withObject:] 9 MyApp -[FlipsideViewController svPhoto] /Users/user/Desktop/MyApp/Classes/FlipsideViewController.m:218 8 0x317fa528 7 0x317e3628 6 0x317e3730 5 0x317edda4 4 0x3180fc74 3 Foundation +[NSThread detachNewThreadSelector:toTarget:withObject:] 2 Foundation -[NSThread start] 1 libSystem.B.dylib pthread_create 0 libSystem.B.dylib malloc I did a test with a new project and only added this code below in the viewDidLoad: NSString *gnTmpStr = [NSString stringWithFormat:@"DefaultTest"]; UIImage *ganTmpImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:gnTmpStr ofType:@"png"]]; // Request to save the image to camera roll UIImageWriteToSavedPhotosAlbum(ganTmpImage, nil, nil, nil); The same leak shows up right after the app loads Thank you for the help. Bryan

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >