memory limits?

Dec 20, 2006 at 4:40pm

memory limits?

We recently had the discussion about the memory limits inside the object
struct due to the 32k limits of getbytes()…

Is there also a Max specific limit when defining globals? I’m currently
running into strange crashes with an external that also compiles as a Pd
external. Under Pd it works fine, in Max it crashes when accesing one of
severl large globals. Previous versions without so many globals were
working fine…
…and no, there seems to be no way of getting rid of them at all, at
least not now.

Olaf

#29312
Dec 20, 2006 at 4:43pm

How large are they, and how are they allocated?

jb

Am 20.12.2006 um 17:40 schrieb Olaf Matthes:

> Under Pd it works fine, in Max it crashes when accesing one of
> severl large globals.

#91299
Dec 20, 2006 at 5:00pm

Jeremy Bernstein wrote:

> How large are they, and how are they allocated?

Like that:

struct some_element *myelem[128][64];

The struct itselfe is about 48 bytes, but for now this is just a pointer…

Then we have two more:

double time[128];
short count[128];

And arrays of t_symbols:

t_symbol *somesymbol[256];

And some smaller ones, giving about 900 t_symbols in total. That’s all
the globals we have.

The symbols get created on first load of object and seem to work (at
least the ones I checked).

It’s crashing when accessing the *myelem[][] although it gets allocated
with getbytes() (I tried sysmem_newptr() as well).

Ah, and this is on latest OS X with Max 4.5.

Olaf

#91300
Dec 20, 2006 at 5:11pm

On Dec 20, 2006, at 9:00 AM, Olaf Matthes wrote:

> struct some_element *myelem[128][64];
> The struct itselfe is about 48 bytes, but for now this is just a
> pointer…

48*128*64=393216 bytes. This is well above the getbytes 32K limit.
Use sysmem_newptr() instead. If you’re *still* having crashes related
to accessing myelem, there’s most likely some other errors in your code.

FWIW, in Max 5 we’re eliminating any difference for getbytes/
freebytes and sysmem_*. So this will be less of a headache for people
in the future. For the time being, however, one needs to be sensitive
to the getbytes() 32k limit.

-Joshua

#91301
Dec 20, 2006 at 6:23pm

Joshua Kit Clayton wrote:

>
> On Dec 20, 2006, at 9:00 AM, Olaf Matthes wrote:
>
>> struct some_element *myelem[128][64];
>> The struct itselfe is about 48 bytes, but for now this is just a
>> pointer…
>
>
> 48*128*64=393216 bytes. This is well above the getbytes 32K limit. Use
> sysmem_newptr() instead. If you’re *still* having crashes related to
> accessing myelem, there’s most likely some other errors in your code.
>
> FWIW, in Max 5 we’re eliminating any difference for getbytes/ freebytes
> and sysmem_*. So this will be less of a headache for people in the
> future. For the time being, however, one needs to be sensitive to the
> getbytes() 32k limit.

Thanks Joshua,

that’s good news with the memory allocation functions.

However, the 32k limit doesn’t seem to be my problem, since we set up
the *elem[][] with fixed size and later on only alloc memory (around 48
bytes) and let elem[i][j] point to it…
I’ll check now whether everything within this struct is pointing to
valid pointers… Sometimes it’s really a pain to have several people
working on the same code.

Olaf

#91302

You must be logged in to reply to this topic.