参考答案和解析
正确答案: 1).你初始化(alloc/init)的对象,你需要释放(release)它。例如: NSMutableArray aArray = [[NSArray alloc] init]; 后,需要 [aArray release]; 
2).你retain或copy的,你需要释放它。例如: [aArray retain] 后,需要 [aArray release]; 
3).被传递(assign)的对象,你需要斟酌的retain和release。例如:obj2 = [[obj1 someMethod] autorelease];
对象2接收对象1的一个自动释放的值,或传递一个基本数据类型(NSInteger,NSString)时:你或希望将对象2进行retain,以防止它在被使用之前就被自动释放掉。但是在retain后,一定要在适当的时候进行释放。
关于索引计数(Reference Counting)的问题 retain值 = 索引计数(Reference Counting) 
NSArray对象会retain(retain值加一)任何数组中的对象。当NSArray被卸载(dealloc)的时候,所有数组中的对象会 被 执行一次释放(retain值减一)。不仅仅是NSArray,任何收集类(Collection Classes)都执行类似操作。例如 NSDictionary,甚至UINavigationController。
Alloc/init建立的对象,索引计数为1。无需将其再次retain。 
[NSArray array]和[NSDate date]等“方法”建立一个索引计数为1的对象,但是也是一个自动释放对象。所以是本地临时对象,那么无所谓了。如果是打算在全Class中使用的变量(iVar),则必须retain它。 
缺省的类方法返回值都被执行了“自动释放”方法。(*如上中的NSArray) 
在类中的卸载方法“dealloc”中,release所有未被平衡的NS对象。(*所有未被autorelease,而retain值为1的)
更多“内存管理 Autorelease、retain、copy、assign的set方法和含义?”相关问题
  • 第1题:

    常用的内存管理方法有:分区管理、页式管理、段式管理和【 】。


    正确答案:段页式管理
    段页式管理

  • 第2题:

    在应用中可以创建多少autorelease对象,是否有限制?


    正确答案:没有限制

  • 第3题:

    简述readwrite,readonly,assign,retain,copy,nonatomic 属性的作用


    正确答案: @property是一个属性访问声明,扩号内支持以下几个属性:
    1).getter=getterName,setter=setterName,设置setter与 getter的方法名
    2).readwrite,readonly,设置可供访问级别
    3).assign,setter方法直接赋值,不进行任何retain操作,为了解决原类型与环循引用问题
    4).retain,setter方法对参数进行release旧值再retain新值,所有实现都是这个顺序(CC上有相关资料)
    5).copy,setter方法进行Copy操作,与retain处理流程一样,先旧值release,再 Copy出新的对象,retainCount为1。这是为了减少对上下文的依赖而引入的机制。
    6).nonatomic,非原子性访问,不加同步,多线程并发访问会提高性能。注意,如果不加此属性,则默认是两个访问方法都为原子型事务访问。锁被加到所属对象实例级。

  • 第4题:

    You need to upgrade the IOS of an existing router on your network. The new IOS image is located on a TFTP server that you have set up within the network. What command should you issue in order to download the new IOS version?()

    • A、Router# copy tftp flash
    • B、Router# copy flash run
    • C、Router(config)# restore flash
    • D、Router(config)# repair flash
    • E、Router#copy flash tftp
    • F、Router# copy start flash

    正确答案:A

  • 第5题:

    You have an Exchange Server 2010 organization that contains 20 mailbox databases. You configure each database to retain all deleted items for 30 days.You need to ensure that all items that pass the retention period are permanently deleted daily between 02:00 and 06:00. Which cmdlet should you use?()

    • A、Set-MailboxDatabase
    • B、Set-MailboxServer
    • C、Set-OrganizationConfig
    • D、Set-RetentionPolicy

    正确答案:A

  • 第6题:

    COPY命令可以备份的文件有()

    • A、数据文件
    • B、控制文件
    • C、Datafilecopy
    • D、Controlfilecopy
    • E、Backup set

    正确答案:A,B,C,D,E

  • 第7题:

    During a boot, which of the following procedures is most likely to present a menu that prompts the user to copy a dump?()

    • A、 Set the dump device to /dev/hd6. 
    • B、 Run sysdumpdev to set the force copy flag for dump to true. 
    • C、 Run sysdumpdev to set the force copy flag for dump to false. 
    • D、 Increase space in the /tmp directory. 

    正确答案:C

  • 第8题:

    Which of the following views must you query to identify any corrupt data file blocks that have been detected during backup set creation?()

    • A、V$COPY_CORRUPT
    • B、V$COPY_CORRUPTION
    • C、V$BACKUP_CORRUPT
    • D、V$BACKUP_CORRUPTION

    正确答案:D

  • 第9题:

    You want to perform a backup of your database to tape. Which backup format can you use?()

    • A、backup set only
    • B、image copy only
    • C、only user-managed backup
    • D、both image copy and backup set
    • E、only incremental image copy backup

    正确答案:A

  • 第10题:

    单选题
    What is an obsolete backup set?()
    A

     A backup set that is missing one or more backup set pieces

    B

     A backup that has exceeded the retention criteria and is no longer needed

    C

     A backup set that does not include archived redo logs

    D

     A backup set that can not be recovered due to corruption

    E

     A backup set superceded by a datafile copy


    正确答案: E
    解析: 暂无解析

  • 第11题:

    填空题
    常用的内存管理方法有()、()、()和()。

    正确答案: 分区管理;页式管理;段式管理;段页式管理
    解析: 暂无解析

  • 第12题:

    单选题
    You need to upgrade the IOS of an existing router on your network. The new IOS image is located on a TFTP server that you have set up within the network. What command should you issue in order to download the new IOS version?()
    A

    Router# copy tftp flash

    B

    Router# copy flash run

    C

    Router(config)# restore flash

    D

    Router(config)# repair flash

    E

    Router#copy flash tftp

    F

    Router# copy start flash


    正确答案: C
    解析: 暂无解析

  • 第13题:

    现网一台基于windows 2003 server操作系统的主机,需要停止业务进行升级,为保证内存中数据的安全,可采用以下哪条命令将内存中的数据写入到硬盘的D盘分区()

    A. copy.exe -c D:

    B. copy.exe -r D:

    C. copy.exe -c D:

    D. sync.exe -r D:


    参考答案:D

  • 第14题:

    属性readwrite,readonly,assign,retain,copy,nonatomic 各是什么作用,在那种情况下用?


    正确答案: 1). readwrite 是可读可写特性;需要生成getter方法和setter方法时
    2). readonly 是只读特性 只会生成getter方法 不会生成setter方法 ;不希望属性在类外改变
    3). assign 是赋值特性,setter方法将传入参数赋值给实例变量;仅设置变量时;
    4). retain 表示持有特性,setter方法将传入参数先保留,再赋值,传入参数的retaincount会+1;
    5). copy 表示赋值特性,setter方法将传入对象复制一份;需要完全一份新的变量时。
    6).nonatomic 非原子操作,决定编译器生成的setter getter是否是原子操作,atomic表示多线程安全,一般使用nonatomic

  • 第15题:

    以下那些是华为全内存面的使用模式?()

    • A、Copy Mode
    • B、Share Mode
    • C、Link Mode
    • D、Pool Mode

    正确答案:A

  • 第16题:

    现网一台基于windows 2003 server操作系统的主机,需要停止业务进行升级,为保证内存中数据的安全,可采用以下哪条命令将内存中的数据写入到硬盘的D盘分区()

    • A、copy.exe -c D:
    • B、copy.exe -r D:
    • C、copy.exe -c D:
    • D、sync.exe -r D:

    正确答案:D

  • 第17题:

    We are enclosing a full set of copy documents ______this first consignment

    • A、referring 
    • B、covering 
    • C、regarding to 
    • D、as for

    正确答案:B

  • 第18题:

    ()主要进行内存的分配和管理,负责对内存的分配和回收,内存的保护和内存的扩充

    • A、内存管理
    • B、处理器管理
    • C、存储管理
    • D、作业管理

    正确答案:C

  • 第19题:

    What is an obsolete backup set?()  

    • A、 A backup set that is missing one or more backup set pieces
    • B、 A backup that has exceeded the retention criteria and is no longer needed
    • C、 A backup set that does not include archived redo logs
    • D、 A backup set that can not be recovered due to corruption
    • E、 A backup set superceded by a datafile copy

    正确答案:B

  • 第20题:

    When CONFIGURE CONTROLFILE AUTOBACKUP is set to ON, RMAN automatically performs a control file autobackup in which three situations?()

    • A、At the end of every RUN block. 
    • B、After every SET CONTROLFILE AUTOBACKUP FORMAT command. 
    • C、After every BACKUP or COPY command issued at the RMAN prompt. 
    • D、At the end of every RUN block if the last command in the block was either BACKUP or COPY. 
    • E、Whenever a BACKUP or COPY command within a RUN block is followed by a command that is neither BACKUP nor COPY. 
    • F、After every BACKUP or COPY command within a RUN block that is followed by the CONFIGURE CONTROLFILE AUTOBACKUP FORMAT command.

    正确答案:C,D,E

  • 第21题:

    常用的内存管理方法有()、()、()和()。


    正确答案:分区管理;页式管理;段式管理;段页式管理

  • 第22题:

    单选题
    During a boot, which of the following procedures is most likely to present a menu that prompts the user to copy a dump?()
    A

     Set the dump device to /dev/hd6. 

    B

     Run sysdumpdev to set the force copy flag for dump to true. 

    C

     Run sysdumpdev to set the force copy flag for dump to false. 

    D

     Increase space in the /tmp directory. 


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    You want to perform a backup of your database to tape. Which backup format can you use?()
    A

    backup set only

    B

    image copy only

    C

    only user-managed backup

    D

    both image copy and backup set

    E

    only incremental image copy backup


    正确答案: B
    解析: 暂无解析