title: UITextView memory leak in ios6?
body: <p>I use iPhone 6 simulator in Xcode. After I add a simple UITextView in my view, I type some word in it. But I found some errors in console:</p>
  
  <pre><code>Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSaveGState: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextDrawLinearGradient: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSetFillColorWithColor: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSetFillColorWithColor: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSaveGState: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextDrawLinearGradient: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSetFillColorWithColor: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextSetFillColorWithColor: invalid context 0x0
  Oct 19 10:07:14 localhost textViewTest[1438] &lt;Error&gt;: CGContextFillRects: invalid context 0x0
  </code></pre>
  
  <p>And when I watch the memory use ,it increase very fast.But when I use iphone5 or iphone4.3 Simulator it will not appear.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#import "ViewController.h"
  #include &lt;sys/sysctl.h&gt;
  #include &lt;mach/mach.h&gt;
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      // Do any additional setup after loading the view, typically from a nib.
      UITextView *textView=[[UITextView alloc] initWithFrame:CGRectMake(0,0,320,50)];
      [self.view addSubview:textView];
      [textView release];
  
      NSTimeInterval timeInterval =5.0 ;
      [NSTimer scheduledTimerWithTimeInterval:timeInterval
                                   target:self
                                 selector:@selector(handleMaxShowTimer:)
                                 userInfo:nil
                                  repeats:YES];
  
  }
  - (double)availableMemory
  {
      vm_statistics_data_t vmStats;
      mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT;
      kern_return_t kernReturn = host_statistics(mach_host_self(),HOST_VM_INFO,(host_info_t)&amp;vmStats,&amp;infoCount);
      if(kernReturn != KERN_SUCCESS)
      {
          return NSNotFound;
      }
      return ((vm_page_size * vmStats.free_count) / 1024.0) / 1024.0;
  }
  
  - (double)usedMemory
  {
      task_basic_info_data_t taskInfo;
      mach_msg_type_number_t infoCount = TASK_BASIC_INFO_COUNT;
      kern_return_t kernReturn = task_info(mach_task_self(),
                                       TASK_BASIC_INFO, (task_info_t)&amp;taskInfo, &amp;infoCount);
      if(kernReturn != KERN_SUCCESS) {
          return NSNotFound;
      }
      return taskInfo.resident_size / 1024.0 / 1024.0;
  }
  
  -(void)handleMaxShowTimer:(NSTimer *)theTimer
  {
      NSLog(@" use memory  %f  remain memory  %f",[self usedMemory],[self availableMemory]);
  
  }
  @end
  </code></pre>