• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: problem encoding large float* matrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem encoding large float* matrix


  • Subject: Re: problem encoding large float* matrix
  • From: James Maxwell <email@hidden>
  • Date: Tue, 1 Dec 2009 12:03:59 -0800

>
> As far as the NSData goes, I'm glad you pointed the redundancy of it out. I'll just encode the bytes themselves.
>

erm... actually, just using:

[aCoder encodeBytes:coincidences length:coincsSize forKey:@"coincidences"];

fails with a complaint about getting a float* when it expects a uint8_t const.
In fact, I know remember that's why I used the NSData in the first place... any thoughts?
This is on 10.6.2, if that means anything.

J.



> Just a note to Sherm that coincidences is malloced as (maxCoincs * inputSize * sizeof(float)), because it's a 2D float array with dimensions maxCoincs x inputSize.
>
> The software is just a research project, for now, so no worries about portability (I'll cross that bridge if I ever get there!).
>
> Now onto the crash that's happening when I try to actually *use* the app after loading from a saved file! ugh... ;-)
>
> thanks all,
>
> J.
>
>
> On 2009-12-01, at 11:40 AM, Sherm Pendley wrote:
>
>> On Tue, Dec 1, 2009 at 1:47 PM, James Maxwell
>> <email@hidden> wrote:
>>> I'm trying to save the state of my app. It chews up a lot of memory, most of which is in large float* matrices. I'm getting an EXC_BAD_ACCESS error in -encodeBytes:length:forKey: and I'm just wondering what might be happening. The float* "coincidences" is a malloced array.
>>>
>>> NSUInteger coincsSize = maxCoincs * inputSize * sizeof(float);
>>
>> This looks suspicious to me. Based on the variable names, it looks
>> like you malloc(maxCoincs * sizeof(float)), then store the actual
>> number of floats in the buffer in inputSize. If that's what you're
>> doing, you only need to multiply by maxCoincs (to get the size of the
>> whole buffer) or by inputSize (to find out how much of the buffer is
>> actually in use) - not by both of them.
>>
>>> NSData* coincData = [NSData dataWithBytesNoCopy:&coincidences length:coincsSize];
>>> [aCoder encodeBytes:[coincData bytes] length:coincsSize forKey:@"coincidences"];
>>
>> As someone else said, if you created the buffer with "coincidences =
>> malloc(...)", then you don't need to dereference it here; doing so
>> will give you the address of the pointer variable, not the address of
>> the buffer to which it points.
>>
>> What's the point of creating the NSData object here? Wouldn't this be
>> just as good?
>>
>>   [aCoder encodeBytes:coincidences length:coincsSize forKey:@"coincidences"];
>>
>> sherm--
>>
>> --
>> Cocoa programming in Perl:
>> http://www.camelbones.org
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: problem encoding large float* matrix
      • From: Jens Alfke <email@hidden>
    • Re: problem encoding large float* matrix
      • From: Quincey Morris <email@hidden>
References: 
 >problem encoding large float* matrix (From: James Maxwell <email@hidden>)
 >Re: problem encoding large float* matrix (From: Sherm Pendley <email@hidden>)
 >Re: problem encoding large float* matrix (From: James Maxwell <email@hidden>)

  • Prev by Date: Re: problem encoding large float* matrix
  • Next by Date: Re: Keyword @defs
  • Previous by thread: Re: problem encoding large float* matrix
  • Next by thread: Re: problem encoding large float* matrix
  • Index(es):
    • Date
    • Thread