Forums > Dev

memory limits?

December 20, 2006 | 4:40 pm

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


December 20, 2006 | 4:43 pm

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.


December 20, 2006 | 5:00 pm

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


December 20, 2006 | 5:11 pm

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


December 20, 2006 | 6:23 pm

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


Viewing 5 posts - 1 through 5 (of 5 total)