Pregunta

Si hago lo siguiente, ¿Hará esto que las pérdidas de memoria?

SomeClass* tmp;
NSDate* thetmpdate;

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date

tmp = [[[SomeClass alloc] init] autorelease];
thetmpdate = [NSDate date];
// Do something long with tmp and date
¿Fue útil?

Solución

No, no hay ninguna fuga en el código que envió. Todos los objetos serán autoreleased cuando se vacía la piscina autorelease, no importa si la variable que contiene los punteros se cambia o no.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top