title: Ran Analyzer : Potential Memory Leak
body: <p><img src="https://i.stack.imgur.com/uDZE2.png" alt="enter image description here"></p>
  
  <p>Hi, </p>
  
  <p>I ran the XCode analyser - and it tells me that the following both are potential memory leaks. 
  I'm not sure why. 
  I declared midiDevices like this </p>
  
  <pre><code>@property (assign, nonatomic) NSMutableArray* midiDevices;
  </code></pre>
  
  <p>Here's the code for openMidiIn</p>
  
  <pre><code>-(void)openMidiIn {
      int k, endpoints;
  
      CFStringRef name = NULL, cname = NULL, pname = NULL;
      CFStringEncoding defaultEncoding = CFStringGetSystemEncoding();
      MIDIPortRef mport = NULL;
      MIDIEndpointRef endpoint;
      OSStatus ret;
  
      /* MIDI client */
      cname = CFStringCreateWithCString(NULL, "my client", defaultEncoding);
      ret = MIDIClientCreate(cname, NULL, NULL, &amp;mclient);
      if(!ret){
          /* MIDI output port */
          pname = CFStringCreateWithCString(NULL, "outport", defaultEncoding);
          ret = MIDIInputPortCreate(mclient, pname, MidiWidgetsManagerReadProc, self, &amp;mport);
          if(!ret){
              /* sources, we connect to all available input sources */
              endpoints = MIDIGetNumberOfSources();
              //NSLog(@"midi srcs %d\n", endpoints);
              for(k=0; k &lt; endpoints; k++){
                  endpoint = MIDIGetSource(k);
                  void *srcRefCon = endpoint;
                  MIDIPortConnectSource(mport, endpoint, srcRefCon);
  
              }
          }
      }
      if(name) CFRelease(name);
      if(pname) CFRelease(pname);
      if(cname) CFRelease(cname);
  
  }
  </code></pre>
  
  <p>Thanks for your help. </p>
  
  <hr>
  
  <p>analyzer info
  Here's more info about the error about making a bit of changes. </p>
  
  <p><img src="https://i.stack.imgur.com/p1thw.png" alt="enter image description here"></p>