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

Emscripten - cannot enlarge memory arrays #574

Closed
hcomere opened this issue Nov 16, 2015 · 3 comments
Closed

Emscripten - cannot enlarge memory arrays #574

hcomere opened this issue Nov 16, 2015 · 3 comments

Comments

@hcomere
Copy link
Contributor

hcomere commented Nov 16, 2015

Hello,

I have generated bgfx for emscripten using "genie --gcc=asmjs gmake" command then i have built metaballs sample using "mingw32-make -C .build/projects/gmake-asmjs config=release example-02-metaballs" command.
Here metaballs sample runs fine.

Now i have copy-pasted the metaball source code to an external project which uses CMake. I link to .build/asmjs/bin/libbgfxRelease.a and .build/asmjs/bin/libexample-commonRelease.a and all compile well with emscripten.
But when i run the sample, i get the following error :

" Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs. "

I added some traces and the error happens when i reach :
bool bgfx::init(...)
{
[....]
s_ctx = BX_ALIGNED_NEW(g_allocator, Context, 16);
}

A sizeof(Context) indicates 19839040 which is higher thant 16777216 indicated by the error message.

Is there any flag setted by genie about memory when it generates the asmjs project ?
Have you any idea about the issue ?

Regards,
Harold

@bkaradzic
Copy link
Owner

This has nothing to do with bgfx. You have to setup your CMake configuration for Emscripten correctly, you probably missing finalize step:
https://github.com/bkaradzic/bx/blob/master/scripts/toolchain.lua#L1112

@hcomere
Copy link
Contributor Author

hcomere commented Nov 16, 2015

Yup, sorry for the off-topic :) I just do not know how to send to you a private message or a simple email .
Adding "-s TOTAL_MEMORY=268435456 " fix the issue, thanks !

Strangely, if i try to add "-s ALLOW_MEMORY_GROWTH=1 " the frame time of metaballs sample increases from 16 to ~40 ... This flag seems to drop some optimisations.

Thank you,

Regard,
Harold

@bkaradzic
Copy link
Owner

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

No branches or pull requests

2 participants