How does the size limit of a single Sui Move object work

I want to understand how the size limit works in Sui move objects. I know that the size limit for a single object is 250kb. Let’s say I am creating an object of the type:

struct Table1 has key, store{
        id: UID,
        list: Table<String, bool>
    }

I create an object calling an init function from a move file:

fun init(ctx: &mut TxContext) { 
        let table_obj = Table1 {
                id: object::new(ctx),
                list: table::new(ctx)
        };
        transfer::public_transfer(channel_list, tx_context::sender(ctx));
   }

Now I keep adding new strings to the table calling this function:

public entry fun add_channel(
        table_obj: &mut Table1,
        elm: String
    ){
        table::add(&mut table_obj.list, elm, true);
    }

Let’s assume each unique string added to the table is of size 10 bytes so for each entry we add 11 bytes (including the boolean value), so the total values that can be added on the object would be 250000/11 ~ 22727 strings. Is there any gap in my understanding, or the upper limit of the data that can be added to the table would be higher (or lower)?

1 Like

The Table collection type is storing both keys and values in dynamic fields Dynamic (Object) Fields | Sui Documentation, which do count against the size limit. So in your example, list can hold an unbounded number of objects, and you’ll never bump into the size limit!

The limit would come into play if you were using a collection type like vector, VecSet, or VecMap that stores collection elements directly rather than using dynamic fields.

3 Likes

Thanks! That clears up things.

1 Like