-
Notifications
You must be signed in to change notification settings - Fork 102
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
Buffer error when reaching 2GB (2.147.869.560) byteLength #116
Comments
See here: KhronosGroup/glTF#2114 |
I don't think it is related to #2114. It is related to the limit of std::ostream to 2GB because we are flushing data in the end of all processes: I think we should flush more frequently to the file in order to avoid the 2GB limit of std::ostream. It has also to do that we have only |
The code issue is not related, but the GLB file format itself cannot be bigger than 2GB because the header uses a uint32 for the length. Even if we fix the code issue, it still won't work. EDIT: Or are you writing to a glTF and not a GLB? |
Ahh, sorry, I'm dumb and I'm not thinking about unsigned. Well, that seems like a bug then. Do you have an easy repro I can use to test the code? |
Unfortunately, I can not share the CAE models, and it is difficult to reproduce without a very big model. I am copying some screenshots with information below. It is seen that if the limit of 2GB is reached while adding accessors through bufferBuilder, then the size of the ostream (in this case it is stream in ram) becomes -1, and failbit and badbit become true. |
Hi, I have found this below but not tested yet as my project is compiled with make and I do not know how to insert this option. In order in C++ to use objects more than 2GB you should set /LARGEADDRESSAWARE in Linker properties in |
It seems that it is OS / Compiler related.
|
On the other side, there is no strict limit if we use std::string instead of std:stringstream. The example below in Windows demonstrates that std::string can easily reach 16GBs. Moreover std::string seems faster and we can also preallocate the memory needed by calculating a priori the number of bytes per indice and vertex (Stringstream does not allow preallocation). However, many things should change in the GLTF-SDK code ... |
It looks like Microsoft's STL implementation limits string buffers to INT_MAX. |
Looks like there were similar issues before: @jimver04 Do you mind filing an issue on Microsoft's STL for your test case? |
@jimver04 I don't know what your code looks like, but |
@bghgary It seems that it is an old issue that never got priority in MSVC. In Gcc the limits seem to be based on __string_type::size_type |
I have also mentioned the issue of 4GB limitation of GLTF to Khronos group: |
I don't see this as an old issue. As I pointed to earlier, the code is checking against INT_MAX and fails to allocate bigger. The two old issues I pointed to are fixed as far as I can tell. I don't see a reason why std::stringstream should be limited to INT_MAX. |
I am trying to use std::string instead of std::stringstream. Why do you have caches ? StreamCache, IStreamCache, StreamCacheLRU ? What do you cache ? The Buffer stream or the File output path ? and why ? |
Hi,
my data to export are very big, and GLTFSDK raises an exception.
totalbyteLength seems not to go beyond 2.147.869.560 bytes.
Do you know the maximum of the offset that ResourceWriter can write ?
How can I extend it ?
L86 @ ResourceWriter.cpp
L34 @ StreamUtils.cpp
I noticed that Buffer and BufferView always have 1 item when exporting to glb.
Shouldn't be more reasonable to have multiple BufferViews and Buffers so as not to reach exceptions?
Best,
Dimitrios
The text was updated successfully, but these errors were encountered: