1

I have very strange problem with Int64 on 32 bit devices. Sample code:

    for i in 0...fromLogEntries.count - 1 {
        if let entryInputID = fromLogEntries[i].inputId?.int64Value {
            if ( entryInputID == inputID ) {
                logEntryToReturn = fromLogEntries[i]
                indexToRemove = i
                break
            }
        }
    }

inputID is property of managed object and is set as Int64 in the model

@NSManaged public var inputId: NSNumber?

The conversion to Int64 is causing the memory to go from 100mb to 500-600 and crash. On 64 bit devices there is no problem at all and no memory increase.

Stefan Nestorov
  • 350
  • 6
  • 14
  • it takes time to convert thats y use multipart api for sending image thats easy and less time consuming – Shobhakar Tiwari Dec 09 '16 at 12:03
  • Sounds like you isolated which line causes trouble. How did you determine that it's the conversion that's the issue? – Andreas Dec 10 '16 at 16:23
  • if let entryInputID = fromLogEntries[i].inputId?.int64Value this is the line. If i comment it its ok. Instruments allocations its showing CFNumber.. or something like that that is allocating like crazy – Stefan Nestorov Dec 10 '16 at 18:40
  • 1
    The quick fix is to use an autorelease pool around the outer loop so that you do not keep allocating NSNumber objects forever: https://stackoverflow.com/questions/25860942/is-it-necessary-to-use-autoreleasepool-in-a-swift-program?rq=1 – MoDJ Dec 12 '16 at 19:27

0 Answers0