Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a bigger size for uint16? #5400

Closed
gotenxds opened this issue Jun 12, 2019 · 4 comments
Closed

Getting a bigger size for uint16? #5400

gotenxds opened this issue Jun 12, 2019 · 4 comments
Labels

Comments

@gotenxds
Copy link

Hello, I'm using the latest compiler with C#
To illustrate the issue I made this simple schema:

`
namespace World;

table WorldTile {
spriteIndex:uint16;
}

root_type WorldTile;
`
I save this data in a vector, there are 100000000 (100^4) items in it

So I would assume the file would be around 200mb, as 100000000 * 2 to mb is 200
but I get 400mb

Note that I get the same result if I change the data type to uint32

@aardappel
Copy link
Collaborator

You are apparently storing the same table in each element of the vector, otherwise the result would would likely be 1.2GB

Tables are stored independently, have a vtable offset (32-bit), and when you create a vector of them, you create offsets to them (32-bit). So your entire file is offsets to the same table.

If you change table to struct in the schema you get the 200mb you expect. More on the difference between these two in the docs.

@gotenxds
Copy link
Author

gotenxds commented Jun 13, 2019

Hi @aardappel thanks for the quick answer, I'm using the createWorldTile(builder, spriteIndex) insdie the loop so I cant really see how it's the same, maybe the spriteIndex is the same so flatbuffers optimizes it ?

@aardappel
Copy link
Collaborator

No, it shouldn't optimize those away automatically.

@github-actions
Copy link

This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants