Comments (16)
There isn't enough information in the bug report to determine what the problem is. Specifically:
- What was leaked?
- The line referenced does not do any allocation. In fact, the method does no allocations, so this method can't "leak" anything.
Since the leak tools (typically) show you the place in the code in which the allocation was made, it is entirely possible to have objects created by JSONKit turn up as leaked objects, but are not leaked due to a bug in JSONKit. For example, if you sending an object returned by JSONKit a retain
message, without a balancing release
, and there are no pointers to the objects that are reachable from the set of "strong roots", then that object will show up as a leak in the tools. The tools will report at what line in the source the object was allocated, but this does not tell you at what point the object was actually leaked.
from jsonkit.
I show the same thing. Look in
static JKDictionary *_JKDictionaryCreate(id *keys, NSUInteger *keyHashes, id *objects, NSUInteger count, BOOL mutableCollection)
The line is
if(JK_EXPECT_F((dictionary->entry = (JKHashTableEntry *)calloc(1UL, sizeof(JKHashTableEntry) * dictionary->capacity)) == NULL)) { [dictionary autorelease]; return(NULL); }
I show 99% next to the line. I have screen shots that follow this memory leak
I am downloading a TON of data and this memory error show very quickly.
My code is as you suggested: I init the decoder when my class is loaded, then I call the objectWithData, over and over and when my class is dealloc, I release the decoder.
I am not retaining or copying the returned json.
I even wrapped the calls in a NSAutoreleasePool and release and it did not resolve the issue.
from jsonkit.
Any update on this?
from jsonkit.
I' d really like to see this fixed. Sooner than later. Any chance a Paid support Session would get this resolved?
from jsonkit.
You should consider using heapshot analysis to resolve your memory issues (http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/).
While it's possible you've found a bug in JSONKit, it's far more likely that your codes' object management strategy is causing the leaks.
from jsonkit.
if its my code id be so happy, i can fix that. ill look into it and report back, thanks for the tip.
from jsonkit.
I have looked into this article and i tried to employ the methods but all of the alloc and retains appear to be happening with in the jsonkit libraries, and everything brings me back to the same line of code.
My code that calls jsonKit is wrapped around a dedicated NSAutorelease pool and I am not copying, retaining etc anything I get form the jsonKit decoder. Would love to see this fixed, it causes my app to crash after about 20-30 mins of syncing. I honestly would pay to have this resolved. If @ohhorob you think this is my code, and would be willing to look at this with me, I would be happy to reimburse you for your time.
from jsonkit.
Can you concoct a simple example that illustrates the issue?
from jsonkit.
I suggest you use the Allocations tool in Instruments with the "Record reference counts" option enabled. It will tell you exactly where the objects are being alloc'd, retained and released.
I'm sorry to have to side against you, but I've used JSONKit a lot myself without coming across memory leaks, so I have to say it sounds like a problem in your own code. We could all be wrong though :)
from jsonkit.
I think I get this issue too although not sure 100%.
The code I have is
__block __typeof__(self) _self = self;
PINKConnectionCompletionBlock complete = ^(PINKConnection *connection, NSError *error) {
if (error) {
NSLog(@"Failed to get data");
} else {
JSONDecoder *decoder = [JSONDecoder decoder];
_self.mainDictionary = [decoder objectWithData:[_self.download downloadData]];
[_self translateToObjectFromDict:_self.mainDictionary];
}
_self.download = nil;
};
self.download = [PINKConnection connectionWithURL:downloadURL
progressBlock:nil
completionBlock:complete];
[self.download start];
And the leak is shown as
http://lesmond.net/images/JSONLeak.png
from jsonkit.
You assigned the object that JSONKit creates to self.mainDictionary
using the following line:
_self.mainDictionary = [decoder objectWithData:[_self.download downloadData]];
... are you sure that in _self
's -dealloc
method you are properly releasing mainDictionary
? I suspect you forgot to [_mainDictionary release];
, or something along those lines (where _mainDictionary
directly references the ivar for the mainDictionary
property).
from jsonkit.
Ah ok thanks, it is actually a Singleton and the mainDictionary is an NSDictionary.
I am not releasing it anywhere so the leak comes on the second run I suppose when I try and set an NSDictionary again and it doesn't dispose of the old object correctly.
Hopefully that is it! Thanks and sorry!
On Wednesday, 14 December 2011 at 17:43, johnezang wrote:
You assigned the object that JSONKit creates to
self.mainDictionary
using the following line:_self.mainDictionary = [decoder objectWithData:[_self.download downloadData]];... are you sure that in
_self
's-dealloc
method you are properly releasingmainDictionary
? I suspect you forgot to[_mainDictionary release];
, or something along those lines (where_mainDictionary
directly references the ivar for themainDictionary
property).
Reply to this email directly or view it on GitHub:
#36 (comment)
from jsonkit.
I'm sorry, but there really is no update. You have provided very little information, other than
- The line in JSONKit that allocates memory for the returned object.
- You are getting "a ton" of leaks.
At this point, JSONKit has been used extensively by a great many people and many apps. This does not mean it is bug free or does not have memory leaks, but more than likely the problem is not with JSONKit.
IMHO, the few clues that you have provided strongly suggest that you have not correctly balanced your retains and releases. As a suggestion, you could try adding an extra autorelease
immediately to the object that JSONKit returns along with enabling zombies. If the extra autorelease
magically fixes things, then the problem is definitely on your end. However, because you are forcibly causing an intentional over-release of the object, it's difficult to say exactly what will happen. With zombies enabled, you'll get a message on the console if anything attempts to send a message to the object after it has been dealloced, which will probably give you a clue as to what and where you over-retained the returned object.
from jsonkit.
From your description, it sounds like you probably have the @property
declaration set to assign
, when it really should be retain
.
from jsonkit.
No it is set to retain.
Sorry to sound like a noob but should I be able to set
self.mainDictionary= aDictionary
After already being set?
On 14 Dec 2011, at 18:09, [email protected] wrote:
From your description, it sounds like you probably have the
@property
declaration set toassign
, when it really should beretain
.
Reply to this email directly or view it on GitHub:
#36 (comment)
from jsonkit.
@johnezang, I believe my problem to be resolved. its not with JsonKit.
Thanks for the reply.
from jsonkit.
Related Issues (20)
- Any popular replacement for JSONKit? HOT 2
- BSD two-clause or three-clause license? HOT 2
- crash at JSONKit.m:2598:77 HOT 2
- Error in serializing NSNumber HOT 2
- Supporting gzip decompression
- Swift HOT 7
- can not use with xcode 7 HOT 4
- Xcode 7 Before is use JSONKit in Object but now not use JSONKit in Xcode 7 HOT 7
- crash with iOS9 Xcode7 HOT 5
- Should be #import <JSONKit/JSONKit.h> or <GCJSONKit/JSONKit.h>? HOT 1
- please ignore
- Crash when NSDictionary to String json format. HOT 1
- about convert json to NSDictioanry (error if json string contains double field) HOT 7
- JsonKit message JSONDataWithOptions crashes in macOS Sierra HOT 1
- JSONKit Installation error in X-code 7.3.1 iOS 9.3 HOT 1
- iOS TRAP_TRACE crash
- JSONKit semantic issue after updating the pod HOT 3
- Tagged pointer format changes in iOS 14 break JSONKit on ARM64 HOT 8
- @serkrapiv Not necessarily verboten, just that they must be escaped. The first paragraph of 2.5 Strings says: HOT 1
- Yea
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsonkit.