---
title: "Convenience Vs init method (memory usage)"  
description: "Convenience Vs init method (memory usage)"  
author: "Anonymous User"  
published: 2015-10-24  
updated: 2015-10-25  
canonical: https://www.mindstick.com/forum/33530/convenience-vs-init-method-memory-usage  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Convenience Vs init method (memory usage)

I tried to create UIImageView object using Convenience and [init method](https://www.mindstick.com/forum/160494/what-is-the-purpose-of-the-init-method-in-a-servlet), after when I try to go back and [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) the [memory usage](https://www.mindstick.com/forum/158210/what-are-some-common-techniques-for-optimizing-memory-usage-in-computer-systems) that are increases after [creation](https://yourviews.mindstick.com/view/85506/what-was-the-causes-of-creation-of-pakistan) of both [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best), the memory usage under the convenience method takes 10MB to 7MB and init method takes from 10MB to 4MB immediately both examples are here:\
Convenience Method:

```
imageView.image = [UIImage imageWithData:[downloads dataAtIndex:0]];
```

init Method:

```
UIImage *aImage = [[UIImage alloc] initWithData:[downloads dataAtIndex:0]];imageView.image = aImage;[aImage release];
```

I also waited and interacted with the app to give time on releasing on the convenience method's autorelease. But it didn't drop much.\
Other than the autorelease vs [release](https://www.mindstick.com/news/2247/apple-plans-to-release-new-macs-in-early-2023), what else contributed the [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is)?

## Replies

### Reply by Tarun Kumar

The only difference that could be causing this is that imageWithData: doesn't use the system image cache, while initWithData: does. So maybe the image that's made with the initializer can release it's image data when it receives a [memory](https://www.mindstick.com/blog/300050/what-causes-sudden-memory-loss) warning since it can go back to the system cache, while the one that's created by the convenience [method](https://www.mindstick.com/forum/166/webservice-method) can't.\
It is advisable to wrap memory intensive operations inside of an NSAutoreleasePool block if you will be making heavy use of them.\


---

Original Source: https://www.mindstick.com/forum/33530/convenience-vs-init-method-memory-usage

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
