English 中文(简体)
目标-记忆问题
原标题:Objective-c Memory Question

我有一个客观的记忆管理问题。 我阅读了有关这个问题的各种文件,但我看不到。 我制作了一个小型样本,以显示我的混乱。 当我发起“评估活动监测”时,它就使用大约7名监测员。 在我执行主食时,记忆使用率达到44元。 然而,当我释放阵列时,我只收到大约14名德国马克参加活动监测。 该机继续使用约30名总经理。 我是否应当把“记忆”回馈到7MB活动监测中?

我做了什么错误?

提前感谢。

The AppDelegate:

- (IBAction) buildArray:(id)sender {
    values = [[NSMutableArray alloc] init]; // values is an instance variable of the appDelegate
    for(int i = 0; i < 500000; ++i) {
        NSString *tempString = [NSString stringWithFormat:@"New Object %i", i];
        [values addObject:tempString];
    }
    [valuesTable reloadData];  // valuesTable is a NSTableView to diplay the array.
}

- (IBAction) clearMemory:(id)sender {
    [values release];
    [valuesTable reloadData];
}

- (int) numberOfRowsInTableView: (NSTableView *) tableView {
    if (values) {
        return [values count];
    } else {
        return 0;
    }
}

- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) tableColumn row: (int) row {
    return [values objectAtIndex:row];
}
最佳回答

此前已多次对此做出答复;但释放物体的行为不会立即恢复系统记忆。 申请被搁置到没有使用的地方,等待重新分配。

如果它们是“实际,则由该系统提供这些资源,但只要没有其他程序需要记忆,你的申请就会被放弃,“视情况而定”。

问题回答

暂无回答




相关问题
Windows Mobile 6 Emulator change storage?

How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: Increasing Windows Mobile 5 Emulator Storage But it only helps for the 5.0 version. Isnt there any way ...

CUDA Memory Allocation accessible for both host and device

I m trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that ...

RAM memory reallocation - Windows and Linux

I am working on a project involving optimizing energy consumption within a system. Part of that project consists in allocating RAM memory based on locality, that is allocating memory segments for a ...

Should I send retain or autorelease before returning objects?

I thought I was doing the right thing here but I get several warnings from the Build and Analyze so now I m not so sure. My assumption is (a) that an object I get from a function (dateFromComponents: ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

doubts regarding Memory management in .net

I m learning about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; ...

Objective-C returning alloc d memory in a function == bad?

This is on the iPhone. So what if I have a function like - (SomeObject*)buildObject; Do I need to pass in a variable that I have already alloc d outside like - (void)assignObject(SomeObject** out);...

热门标签