memory-management

Memory leaks destroying my application?

半世苍凉 提交于 2019-12-24 18:16:13
问题 I'm in big trouble now, my iPhone application keep terminating again and again due to memory leaks and I am unable to judge that where are those leaks . Tell me what step can I take in order to resolve this problem. Thanks 回答1: I think you're confusing terminology here. A memory leak is when you don't release an object after you're done with it. A leak won't directly cause a crash . Leaks can indirectly cause crashes if you run out of memory as a result of not releasing lots of objects.

Break A Large File Into Many Smaller Files With PHP

本秂侑毒 提交于 2019-12-24 18:12:48
问题 I have a 209MB .txt file with about 95,000 lines that is automatically pushed to my server once a week to update some content on my website. The problem is I cannot allocate enough memory to process such a large file, so I want to break the large file into smaller files with 5,000 lines each. I cannot use file() at all until the file is broken into smaller pieces, so I have been working with SplFileObject. But I have gotten nowhere with it. Here's some pseudocode of what I want to accomplish:

Deleting dynamic arrays?

会有一股神秘感。 提交于 2019-12-24 18:09:06
问题 I'm having problems about deleting dynamic arrays in my project. First appear: void StudentReviewSystem::addCourse( const int courseId, const string courseName ) { int i = findCourse( courseId ); if ( i == -1 ) { int newNum = numberOfCourses + 1; Course *newCourses = new Course[newNum]; for ( int j = 0; j < numberOfCourses; j++ ) { newCourses[j] = courses[j]; } Course aCourse(courseId, courseName); newCourses[numberOfCourses] = aCourse; //delete[] courses; courses = newCourses;

Should I make stack segment large or heap segment large?

耗尽温柔 提交于 2019-12-24 17:35:11
问题 I'm programming a design for a microprocessor with very limited memory and I must use "a lot" of memory in different functions. I can't have a large stack segment, heap segment, data segment, I must choose which to make big and which to make small. I have about 32KB total, I use about 20KB for the text segment, that gives me 12KB for the rest. And I need a buffer of 4KB to pass to different functions (SPI Flash sector size). Where should initialize that large buffer? So my choices are: 1) If

Free() returned char pointer doesn't remove it from memory?

非 Y 不嫁゛ 提交于 2019-12-24 17:25:00
问题 Basically the problem comes down to this: I load a file, write all the each character into a char* variable which has malloc() the length of the file. Then I return that variable and print it, then I free() the memory for that variable and try to print the variable again which does print it. I'm very new to C so there is probably something wrong in the way I handle the memory for the variable that holds the text content. I tried using char[(ftell(file)] instead of malloc and char*, but then

Not enough memory or not enough handles?

核能气质少年 提交于 2019-12-24 17:23:56
问题 I am working on a large scale project where a custom (pretty good and robust) framework has been provided and we have to use that for showing up forms and views. There is abstract class StrategyEditor (derived from some class in framework) which is instantiated whenever a new StrategyForm is opened. StrategyForm (a customized window frame) contains StrategyEditor . StrategyEditor contains StrategyTab . StrategyTab contains StrategyCanvas . This is a small portion of the big classes to clarify

Not enough memory or not enough handles?

假如想象 提交于 2019-12-24 17:23:55
问题 I am working on a large scale project where a custom (pretty good and robust) framework has been provided and we have to use that for showing up forms and views. There is abstract class StrategyEditor (derived from some class in framework) which is instantiated whenever a new StrategyForm is opened. StrategyForm (a customized window frame) contains StrategyEditor . StrategyEditor contains StrategyTab . StrategyTab contains StrategyCanvas . This is a small portion of the big classes to clarify

Out of memory exception when not using all the memory/limits

一世执手 提交于 2019-12-24 17:15:57
问题 We have an issue here where we can have some OutOfMemoryException . We will check how we can reduce the memory usage, but my question is why I get it at this point . According to the Memory profiler, and the windows task manager, the application weights only 400MB. For what I understood(confirmed here), for 32bits applications, the limitation should be around 2GB. My computer has 16GB of ram, and there is plenty of ram available(more than 4GB). So why do I get this error now? My question is

linux x64 c++ allocates way too much memory for a linked list; why?

﹥>﹥吖頭↗ 提交于 2019-12-24 17:09:18
问题 i will be using linked list example code seen here on stackoverflow to illustrate the problem. my c++ written progam (x64) contains this linked list code : old code snippets deleted; im sorry if comments doesnot make sense anymore. added fully working code to show what my problem is. compile : g++ linkedlist.cpp -o linked-list #include <cstdlib> #include <iostream> using namespace std; struct node { public : unsigned int part1; // 4 bytes unsigned int part2; // 4 bytes node *next; //pointer,

Why are some object members out of scope in Objective C

痞子三分冷 提交于 2019-12-24 15:48:58
问题 I'm coming to Objective-C from a Java background. I'm having trouble understanding why the following code generates an exception. @interface Stopwatch : NSObject { NSDate *start; int mode; } @property(nonatomic,assign) NSDate *start; @property(nonatomic,assign) int mode; @end @implementation Stopwatch @synthesize start, mode; -(id) init{ self = [super init]; if(self){ start = [NSDate date]; mode = -1; } return self; } @end @interface StopwatchController : NSObject { Stopwatch *stopwatch; }