Ehsan Khodarahmi
Ehsan Khodarahmi

Reputation: 4932

Best data structure for sequential storing of variable-length objects on a limited memory

I have a limited fixed amount of memory on a MCU, on which I should store some objects. The amount of memory is very small and I must allocate all the memory for storing objects at the begining of program (I can't use dynamic memory allocation).

Each object consists of several attributes and we can add or remove any number of attributes for any object at any time. The attributes lengths are variable so the length of objects may varies from time to time. The size of an attribute may change when this attribute is modified.

The key operation on stored objects is searching and reading attribute values.

Now, I'm looking for the best way and the best data structure (fast, not much metadata, few memory writes, small search overhead) that covers my problem.

Any idea?

Upvotes: 1

Views: 476

Answers (1)

jrouquie
jrouquie

Reputation: 4425

This still looks like dynamic memory allocation, you might write a lightweight version of malloc/free.

If you have some prior knowledge on the stored object, maybe you can structure your memory accordingly, but it seems in your question that you are specifically looking for a general purpose algorithm.

Upvotes: 1

Related Questions