zoukankan      html  css  js  c++  java
  • 【OC语法快览】四、基础内存管理

    Basic Memory Management                                                       

       基础内存管理

    If you're writing an application for Mac OS X, you have the option to enable garbage collection. In general, this means that you don't have to think about memory management until you get to more complex cases. 
    假设你正在写执行在Mac OS X上的程序,你能够选择开启垃圾回收功能。除非你遇到更复杂的情况。这样你就不用考虑内存管理了。



    However, you may not always be working with an environment that supports garbage collection. In that case, you need to know a few basic concepts. 

    可是,你的工作环境不一定都支持垃圾回收。

    这样的情况下。你须要知道一些基本内存管理的概念。

    If you create an object using the manual alloc style, you need to releasethe object later. You should not manually release an autoreleased object because your application will crash if you do. 

    假设使用人工alloc方式创建实例对象,稍后须要释放掉它。

    不应该人工释放一个能够自己主动释放的对象,否则将导致程序奔溃。

    Here are two examples:

    这有两个样例: 

    // string1 will be released automatically
    NSString* string1 = [NSString string];
    
    // must release this when done
    NSString* string2 = [[NSString alloc] init];
    [string2 release];



    For this tutorial, you can assume that an automatic object will go away at the end of the current function. 
    在这份材料中,你能够如果。一个自己主动释放的实例对象将会在当前函数结束后自己主动消失。

    There's more to learn about memory management, but it will make more sense after we look at a few more concepts.
    还有非常多须要学习的内存管理知识,可是在我们掌握很多其它概念之后,学习起来更有效果。






    原文:learn_objective_C part 4

  • 相关阅读:
    普通百姓如何应对通货膨胀
    经济
    将到来的战略转变:移动 Web 还是移动 Apps?
    ASP.Net 第一天笔记 MVC 控制器与视图数据传递注意事项
    关于阿里云 ETC服务器 端口开放问题
    .net 委托 +lamda表达式
    de4Dot用法 解决 .net程序 reflecter反编译 “索引超出了数组界限”问题
    fastReport.net 初了解
    关于JQuery Ajax 跨域 访问.net WebService
    JQuery AJAX 通过一般处理程序 取列表
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5274554.html
Copyright © 2011-2022 走看看