What is the correct way to handle memory allocation failure reported from third party libraries?

31 views
Skip to first unread message

Koji Ishii

unread,
Nov 24, 2016, 7:24:02 AM11/24/16
to platform-architecture-dev
When we use third-party libraries such as ICU, they may report memory allocation failures. In many places in our layout code, we skip part of the processing in such case, but silently doing incorrect layout on memory allocation failure makes me wonder whether this is the correct thing to do or not.

IIUC when we fail to allocate our own objects, we crash, correct? If so, should we just use CHECK and crash in such cases?

Thoughts appreciated in advance.

/koji

Kentaro Hara

unread,
Nov 24, 2016, 7:47:19 AM11/24/16
to Koji Ishii, platform-architecture-dev
If it's OOM, there's almost nothing we can do there (although we might be able to prolong the life of a renderer by forcing GCs and reducing the memory consumption temporarily). So it's okay to just crash when you hit an OOM.

However, to distinguish the OOM crash from other crashes, it's important to crash the renderer with OOM_CRASH(). See this code for example.




--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architecture-dev+unsub...@chromium.org.
To post to this group, send email to platform-architecture-dev@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/platform-architecture-dev/CACQRE%2BRptdF2EEJDmsnePZx%3Di%2BXFB%2Bphi9F%2BjJxW9pTYQhiKDg%40mail.gmail.com.



--
Kentaro Hara, Tokyo, Japan

Koji Ishii

unread,
Nov 24, 2016, 7:51:31 AM11/24/16
to Kentaro Hara, Koji Ishii, platform-architecture-dev
Thank you for your prompt response, I'll make sure we use OOM_CRASH for U_MEMORY_ALLOCATION_ERROR (in the case of ICU) and other appropriate failures otherwise.

/koji

On Thu, Nov 24, 2016 at 9:46 PM, Kentaro Hara <har...@chromium.org> wrote:
If it's OOM, there's almost nothing we can do there (although we might be able to prolong the life of a renderer by forcing GCs and reducing the memory consumption temporarily). So it's okay to just crash when you hit an OOM.

However, to distinguish the OOM crash from other crashes, it's important to crash the renderer with OOM_CRASH(). See this code for example.



On Thu, Nov 24, 2016 at 9:23 PM, Koji Ishii <ko...@chromium.org> wrote:
When we use third-party libraries such as ICU, they may report memory allocation failures. In many places in our layout code, we skip part of the processing in such case, but silently doing incorrect layout on memory allocation failure makes me wonder whether this is the correct thing to do or not.

IIUC when we fail to allocate our own objects, we crash, correct? If so, should we just use CHECK and crash in such cases?

Thoughts appreciated in advance.

/koji

--
You received this message because you are subscribed to the Google Groups "platform-architecture-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to platform-architecture-dev+unsubsc...@chromium.org.
Reply all
Reply to author
Forward
0 new messages