Reputation: 335
I am working with RapidJSON and trying to serialize a rapidjson::GenericDocument
object using rapidjson::PrettyWriter
to a rapidjson::GenericStringBuffer
. Here is the relevant part of my code:
typedef rapidjson::GenericDocument<rapidjson::UTF16<> > WDocument;
typedef rapidjson::GenericStringBuffer<rapidjson::UTF16<> > WStringBuffer;
WStringBuffer buffer;
PrettyWriter<WStringBuffer, WDocument::EncodingType> writer(buffer);
doc.Accept(writer);
While writing to the buffer(using Accept method), I am encountering a "Write Access Violation" exception. Upon debugging, I observed that the violation is caused because the stack_
(which RapidJSON uses to store the strings) of the string buffer is null.
From my understanding, this stack_
should dynamically expand depending on the data being written to the buffer. The only reason for this stack_
to be null should be a memory allocation failure.
However, the process running this code is a 32-bit process, and the maximum memory it consumed, as observed in Task Manager, is about 800 MB (which is less than the memory available for the process).
I found an issue on GitHub (835), related to stack_
. This seems to be similar to the problem I am facing.
I am unable to figure out the reason for this failure and have been stuck on this for a long time. Any help or insights would be greatly appreciated.
Upvotes: 0
Views: 71