0

I have done xml parsing same as SeismicXML example. But now it gives me memory leak problem.

When i tested SeismicXML with instruments, it also give same memory leak.

In SeismicXML, EarthQuake example is there, it contains all the string and array which come from xml parsing. SO 'Leak' instruments showing all this string and array as leaked objects.

I spent lot time behind this issue. but i couldn't solve yet. If anybody has solve this issue then pls share your review with me.

Thanks, Haresh.

3 Answers3

0

Before I initialize my NSXMLParser I set the following:

[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:URL];

This stops leaking.

leviathan
  • 11,080
  • 5
  • 42
  • 40
0

You may want to download, install and use the CLANG checker tool to understand why your code is leaking memory. This tool (which is already built for Leopard 10.5.x) may sometimes fail to provide the correct answer, but in my personal experience it never failed. I highly recommend it as one of your daily development tools.

You can download it from

http://clang.llvm.org/StaticAnalysis.html

Usage it really simple. Take a look at

http://clang.llvm.org/StaticAnalysisUsage.html#BasicUsage

In practice, you simply build your Xcode project using the command

scan-build -k -V xcodebuild

then, you inspect the resulting output HTML files using the command that will appears as output in your terminal window. These files will give you a detailed explanation of why something is wrong in your code (not just memory leaks).

Kind regards

Massimo Cafaro
  • 25,429
  • 15
  • 79
  • 93
0

ok,

I am supposing you correctly installed the tool so that you can invoke it from a terminal.

To use it:

1) cd /your/project/path 2) scan-build -k -V xcodebuild

if this does not work then you have not installed the tool correctly: at least you do not have your "path" correctly set.

Here is how to set the path for c or tcsh shell , asuming you installed the tool in /opt/checker-0.160

set mypath=(/opt/checker-0.160) set path=($mypath $path)

3) if the command works correctly, it build your project and starts a web server on your machine. It then gives you the url where you can connect to on your machine to read the results.

If the command is not able to start a web server, it will anyway tell you that the html files are available in a specific directory and you will be given the path. Usually this directory is to be found under /tmp.

Simply go to this directory

cd /path/to/results/directory

and then

open index.html

You will see the full report. Best Regards.

Massimo Cafaro
  • 25,429
  • 15
  • 79
  • 93