[SERVER-12714] Eliminate uses of realloc/malloc/free in C++ code Created: 13/Feb/14  Updated: 05/Dec/23  Resolved: 05/Dec/23

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Andy Schwerin Assignee: Backlog - Service Architecture
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-12752 Eliminate direct uses of C allocation... Closed
Related
related to SERVER-14889 report out of memory error when mallo... Closed
Assigned Teams:
Service Arch
Sprint: Execution Team 2022-12-12, Execution Team 2022-12-26, Execution Team 2023-01-09
Participants:

 Description   

The allocators we use don't have advantageous realloc behavior, and using malloc/free in C++ code prevents us from letting the "new handler" abort on allocation failures. That, in turn, leads us to a highly suspect set of macros in allocator.h, that may cause ODR violations or other surprising behaviors.

The solution is to replace uses of malloc with new, free with delete and realloc with new, memcpy and delete, if they can't be eliminated outright.



 Comments   
Comment by Steven Vannelli [ 04/Dec/23 ]

Sending this to Service Arch to evaluate the benefit of this will be as they own the allocator.

Generated at Thu Feb 08 03:29:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.