Shop Learn P1 Docs P2 Docs
PROP2 Memory Free - function or command? — Parallax Forums

PROP2 Memory Free - function or command?

PropGuy2PropGuy2 Posts: 348
edited 2022-07-26 14:36 in Propeller 2

Maybe I missed it - But does the PROP2 library have any memory Free, or memory Used functions or commands ? If not, Are there any work-a-rounds ?
Something like:
value := USED(x ) 'returns the number of HUB/RAM bytes used (code & data) in a Prop2 program

FYI, It would be nice to have.

Comments

  • evanhevanh Posts: 13,619

    I guess you are referring to the Spin2 language. Probably the closest there is to memory management in Spin2 is just the VAR and DAT sections. Certainly no malloc() like functions built in.

    I'm not sure how clean an "object" could handle implementing a general layer under all other objects. That'd be the closest to making your own library.

  • evanhevanh Posts: 13,619

    PS: I think one reason for design of Spin language was do away with dynamic memory structures. To avoid the pitfalls that come with such.

  • pik33pik33 Posts: 1,758

    While in flexbasic I used __builtin_alloca for this purpose. It allocates a memory on a top of the stack and returns a pointer to it, so you can know where is the top of the stack, and this is also a top of Flexbasic used memory (code->heap->stack, growing up)

    Of course this is the main stack and it can grow up more after this.

Sign In or Register to comment.