AlexDenisov / iActiveRecord

ActiveRecord for iOS without CoreData, only SQLite
http://alexdenisov.github.com/iActiveRecord/
MIT License
354 stars 50 forks source link

Leaks with NSDate #40

Open wsnnn opened 11 years ago

wsnnn commented 11 years ago

Faced with such a problem: with each operation with a base leak. Xcode Instruments indicates iActiveRecord [NSDate dateWithTimeIntervalSince1970:] and [NSDate dateWithTimeIntervalSinceNow:]

//on the Russian Столкнулся с такой проблемой: при каждой операции с базой происходят утечки. Xcode Instruments указывает на iActiveRecord [NSDate dateWithTimeIntervalSince1970:] и [NSDate dateWithTimeIntervalSinceNow:] leaks

AlexDenisov commented 11 years ago

Hi @wsnnn, could you describe steps to reproduce?

AlexDenisov commented 11 years ago

And which version do you use?

wsnnn commented 11 years ago

Hi! Download stable version 29.06.2013.

Here is the sample project. Tested on the iPad. The results are the same as above. http://yadi.sk/d/a4NYU6gV6P4-4

AlexDenisov commented 11 years ago

Thank you, I'll review it soon.

AlexDenisov commented 11 years ago

Could you try the new version from master branch? stable branch have a lot of bugs, and now I've implemented AR with the new API

Here is #35 some discussion, also you may review ActiveTwitter target.

P.S. or you can drop me on skype: debian.1101

wsnnn commented 11 years ago

Tried master. The same. Added class_getSubclasses

AlexDenisov commented 11 years ago

Fixed on stable branch. But I cannot reproduce this on master...

wsnnn commented 11 years ago

By the way, ActiveTwitter uses old API http://search.twitter.com/search.json?q=test

AlexDenisov commented 11 years ago

f**k, I will fix it.

wsnnn commented 11 years ago

Maybe this will help http://yadi.sk/d/4C4WG0Qk6PIuM

wsnnn commented 11 years ago

stable ARTest(68825,0x3d1a0b88) malloc: * error for object 0x1f5d4890: pointer being freed was not allocated. * set a breakpoint in malloc_error_break to debug

AlexDenisov commented 11 years ago

I will review this at the evening. Anyway, I highly recommend to use version from master.

wsnnn commented 11 years ago

While I use master. Since AR is used in the life cycle very often, the leaks are very large.

AlexDenisov commented 11 years ago

I can't understand where is the problem. I had the same trace for stable, but master' trace looks good, without leaks.

wsnnn commented 11 years ago

Master shows on each call to the database: malloc: *\ error for object 0x1f5d4890: pointer being freed was not allocated.

AlexDenisov commented 11 years ago

Have you called [ActiveRecord applyConfiguration... at the app start?

wsnnn commented 11 years ago

No

AlexDenisov commented 11 years ago

Could you try and leave a feedback?

wsnnn commented 11 years ago

Posted on your mail

holin commented 11 years ago

Any thing new? I have this issue too.

alexiscreuzot commented 11 years ago

+1

alexgaribay commented 11 years ago

Update please?

AlexDenisov commented 11 years ago

Guys, could someone give me a test project with these leaks?

alexgaribay commented 11 years ago

@AlexDenisov I sent you an email with a failing project presuming the email listed in the wiki is yours.

AlexDenisov commented 11 years ago

@alexgaribay, I've received your email and will review it soon, thanks.

ghost commented 10 years ago

Any updates on this? I am trying to set a property of type NSDate to something, then update the entity, but it saves null. @AlexDenisov

alexiscreuzot commented 10 years ago

I think it wouldn't be a bad idea to save dates as timestamps (NSNumber) for now, at least until the problem is resolved.

ghost commented 10 years ago

@kirualex Yeah you could even save them as ISO8601 strings but that isn't solving the problem, I don't like spikes sitting somewhere in my app. Plus to that, changing even a small property like that results in a lot of refactor.

AlexDenisov commented 10 years ago

I still can't reproduce it nor on master branch, nor on stable.

AlexDenisov commented 10 years ago

@nemesis-fw, regarding your issue with null date: have you marked the property as @dynamic?

ghost commented 10 years ago

@AlexDenisov Yes, I most certainly did.

ghost commented 10 years ago

By the way, my NSDate property is somehow getting converted into an NSNumber. Why is that? Did any of you encounter something similar to this?

alexgaribay commented 10 years ago

@nemesis-fw I noticed this as well. I have to change my models to not use actual dates but to use NSNumber to hold time since 1970. For me, NSDate would sometimes come as an NSDate or it would NSNumber. So I just settled on using NSNumber.

So my work around is doing this:

Saving a date

model.date = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];

Getting a date

NSTimeInterval time = [model.date doubleValue];
NSDate* theDate = [[NSDate alloc] initWithTimeIntervalSince1970:time];
juanpare commented 10 years ago

I have same error using only one model with a NSString, this is frustrating.

alexiscreuzot commented 10 years ago

As this project is labeled as discontinued, I moved on to use ObjectiveRecord. It follows the same principles that iActiveRecord, but is wrapping CoreData instead of directly SQLite.