Starboard Module Reference: memory_reporter.h
Stay organized with collections
Save and categorize content based on your preferences.
DEPRECATED: Provides an interface for memory reporting.
Typedefs
SbMemoryReporterOnAlloc
A function to report a memory allocation from SbMemoryAllocate(). Note that
operator new calls SbMemoryAllocate which will delegate to this callback.
Definition
typedef void(* SbMemoryReporterOnAlloc) (void *context, const void *memory, size_t size)
SbMemoryReporterOnDealloc
A function to report a memory deallocation from SbMemoryDeallcoate(). Note that
operator delete calls SbMemoryDeallocate which will delegate to this callback.
Definition
typedef void(* SbMemoryReporterOnDealloc) (void *context, const void *memory)
SbMemoryReporterOnMapMemory
A function to report a memory mapping from SbMemoryMap().
Definition
typedef void(* SbMemoryReporterOnMapMemory) (void *context, const void *memory, size_t size)
SbMemoryReporterOnUnMapMemory
A function to report a memory unmapping from SbMemoryUnmap().
Definition
typedef void(* SbMemoryReporterOnUnMapMemory) (void *context, const void *memory, size_t size)
Structs
SbMemoryReporter
SbMemoryReporter allows memory reporting via user-supplied functions. The void*
context is passed to every call back. It's strongly recommended that C-Style
struct initialization is used so that the arguments can be typed check by the
compiler. For example, SbMemoryReporter mem_reporter = { MallocCallback, ....
context };
Members
SbMemoryReporterOnAlloc on_alloc_cb
Callback to report allocations.
SbMemoryReporterOnDealloc on_dealloc_cb
Callback to report deallocations.
SbMemoryReporterOnMapMemory on_mapmem_cb
Callback to report memory map.
SbMemoryReporterOnUnMapMemory on_unmapmem_cb
Callback to report memory unmap.
void * context
Optional, is passed to callbacks as first argument.
Functions
SbMemorySetReporter
Sets the MemoryReporter. Any previous memory reporter is unset. No lifetime
management is done internally on input pointer.
NOTE: This module is unused starting with Starboard 15 and will be removed in
the future.
Returns true if the memory reporter was set with no errors. If an error was
reported then check the log for why it failed.
Note that other than a thread-barrier-write of the input pointer, there is no
thread safety guarantees with this function due to performance considerations.
It's recommended that this be called once during the lifetime of the program, or
not at all. Do not delete the supplied pointer, ever. Example (Good):
SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter);
... SbMemorySetReporter(NULL); // allow value to leak. Example (Bad):
SbMemoryReporter* mem_reporter = new ...; SbMemorySetReporter(&mem_reporter);
... SbMemorySetReporter(NULL); delete mem_reporter; // May crash.
Declaration
bool SbMemorySetReporter(struct SbMemoryReporter *tracker)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eThis module, which provides an interface for memory reporting, is deprecated and will be removed in future versions (starting with Starboard 15).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSbMemoryReporter\u003c/code\u003e is a struct that allows memory reporting through user-defined functions, passing a user-provided context to each callback.\u003c/p\u003e\n"],["\u003cp\u003eThe module defines callbacks (\u003ccode\u003eSbMemoryReporterOnAlloc\u003c/code\u003e, \u003ccode\u003eSbMemoryReporterOnDealloc\u003c/code\u003e, \u003ccode\u003eSbMemoryReporterOnMapMemory\u003c/code\u003e, \u003ccode\u003eSbMemoryReporterOnUnMapMemory\u003c/code\u003e) to report memory allocation, deallocation, mapping, and unmapping, respectively.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eSbMemorySetReporter\u003c/code\u003e function sets the memory reporter, and it is recommended to be called once during the program's lifetime due to lack of thread safety and performance considerations.\u003c/p\u003e\n"],["\u003cp\u003eWhen using \u003ccode\u003eSbMemorySetReporter\u003c/code\u003e, the supplied pointer should not be deleted, and setting it to NULL will simply allow the memory to leak.\u003c/p\u003e\n"]]],["This defines a memory reporting interface, now deprecated. It provides callbacks for memory events: `on_alloc_cb`, `on_dealloc_cb`, `on_mapmem_cb`, and `on_unmapmem_cb`. The `SbMemoryReporter` struct stores these callbacks and an optional context pointer. `SbMemorySetReporter` sets the memory reporter, replacing any existing one. It has thread safety limitations and does not manage the reporter's lifetime, advising against deleting the pointer after setting it.\n"],null,["DEPRECATED: Provides an interface for memory reporting.\n\nTypedefs\n\nSbMemoryReporterOnAlloc\n\nA function to report a memory allocation from SbMemoryAllocate(). Note that\noperator new calls SbMemoryAllocate which will delegate to this callback.\n\nDefinition \n\n typedef void(* SbMemoryReporterOnAlloc) (void *context, const void *memory, size_t size)\n\nSbMemoryReporterOnDealloc\n\nA function to report a memory deallocation from SbMemoryDeallcoate(). Note that\noperator delete calls SbMemoryDeallocate which will delegate to this callback.\n\nDefinition \n\n typedef void(* SbMemoryReporterOnDealloc) (void *context, const void *memory)\n\nSbMemoryReporterOnMapMemory\n\nA function to report a memory mapping from SbMemoryMap().\n\nDefinition \n\n typedef void(* SbMemoryReporterOnMapMemory) (void *context, const void *memory, size_t size)\n\nSbMemoryReporterOnUnMapMemory\n\nA function to report a memory unmapping from SbMemoryUnmap().\n\nDefinition \n\n typedef void(* SbMemoryReporterOnUnMapMemory) (void *context, const void *memory, size_t size)\n\nStructs\n\nSbMemoryReporter\n\nSbMemoryReporter allows memory reporting via user-supplied functions. The void\\*\ncontext is passed to every call back. It's strongly recommended that C-Style\nstruct initialization is used so that the arguments can be typed check by the\ncompiler. For example, SbMemoryReporter mem_reporter = { MallocCallback, ....\ncontext };\n\nMembers\n\n- `SbMemoryReporterOnAlloc on_alloc_cb`\n\n Callback to report allocations.\n- `SbMemoryReporterOnDealloc on_dealloc_cb`\n\n Callback to report deallocations.\n- `SbMemoryReporterOnMapMemory on_mapmem_cb`\n\n Callback to report memory map.\n- `SbMemoryReporterOnUnMapMemory on_unmapmem_cb`\n\n Callback to report memory unmap.\n- `void * context`\n\n Optional, is passed to callbacks as first argument.\n\nFunctions\n\nSbMemorySetReporter\n\nSets the MemoryReporter. Any previous memory reporter is unset. No lifetime\nmanagement is done internally on input pointer.\n\nNOTE: This module is unused starting with Starboard 15 and will be removed in\nthe future.\n\nReturns true if the memory reporter was set with no errors. If an error was\nreported then check the log for why it failed.\n\nNote that other than a thread-barrier-write of the input pointer, there is no\nthread safety guarantees with this function due to performance considerations.\nIt's recommended that this be called once during the lifetime of the program, or\nnot at all. Do not delete the supplied pointer, ever. Example (Good):\nSbMemoryReporter\\* mem_reporter = new ...; SbMemorySetReporter(\\&mem_reporter);\n... SbMemorySetReporter(NULL); // allow value to leak. Example (Bad):\nSbMemoryReporter\\* mem_reporter = new ...; SbMemorySetReporter(\\&mem_reporter);\n... SbMemorySetReporter(NULL); delete mem_reporter; // May crash.\n\nDeclaration \n\n bool SbMemorySetReporter(struct SbMemoryReporter *tracker)"]]