How much memory allocate when reading save blob with XGameSaveReadBlobData

Alekseev Maksim Valentinovich 0 Reputation points
2025-11-24T16:09:27.5766667+00:00

I'm implementing game save logic and need to write a function that reads data from a single XGameSaveBlob. The documentation for XGameSaveReadBlobData explains how to use it, but it feels incomplete and even partially incorrect. For example, there’s no implementation of the _GetContainerBlobsDataSize method, which is supposed to define the amount of memory required.

I found what seems to be an implied implementation in another documentation page (XGameSaveEnumerateBlobInfo), but that doesn’t make sense — I don’t see why the value of sizeof(XGameSaveBlob) should be added to the allocated space.

Additionally, the documentation for XGameSaveBlobInfo states that XGameSaveBlobInfo::size represents the size of the XGameSaveBlob. However, when I look at the included header in my codebase, the comments there contradict the documentation.

struct XGameSaveBlobInfo
{
    _Field_z_ const char* name;  // unique blob name (unique to container)
    uint32_t size;           // size of the saved data
};
struct XGameSaveBlob
{
    XGameSaveBlobInfo info;  // metadata
    uint8_t* data;           // saved data
};

So my question is: what is the correct way to determine how much memory to allocate for a single XGameSaveBlob when reading, given these inconsistencies in the documentation?

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-11-24T16:09:45.0333333+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To determine the correct amount of memory to allocate for a single XGameSaveBlob when reading, you should consider the following:

    1. Size of the Blob Data: The XGameSaveBlobInfo::size field represents the size of the saved data within the blob. This is the primary value you will need to allocate memory for the actual data.
    2. Size of the Blob Structure: You also need to account for the size of the XGameSaveBlob structure itself, which includes the XGameSaveBlobInfo metadata and the pointer to the data. Therefore, the total memory allocation should be the size of the blob data plus the size of the XGameSaveBlob structure.
    3. Implementation Considerations: When implementing the function, you can calculate the total memory allocation as follows:
         size_t totalSize = sizeof(XGameSaveBlob) + blobInfo.size;
      
      This ensures that you allocate enough memory for both the metadata and the actual saved data.

    If you find discrepancies in the documentation or header comments, it may be helpful to cross-reference with other parts of the SDK or seek clarification from the documentation team or community forums. However, the approach outlined above should provide a solid basis for your memory allocation needs when reading from a XGameSaveBlob.


    References:


  2. Susmitha T (INFOSYS LIMITED) 1,630 Reputation points Microsoft External Staff
    2025-11-25T10:46:54.6866667+00:00

    Thank you for reaching out!

    To correctly determine the memory allocation for a single XGameSaveBlob, you should account for the following components:

    1. Blob Data Size Use XGameSaveBlobInfo::size to represent the actual saved data size.
    2. Size Field Include sizeof(uint32_t) for storing the blob data size.
    3. Blob Name Add strlen(blobInfo.name) + 1 to accommodate the blob name and its null terminator.

    Correct formula:  size_t totalSize = blobInfo.size       // actual data

                     + sizeof(uint32_t) // size field

     

     

    Let me know if you need any further help with this. I will be happy to assist.

    If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.