Skip to content

unable to allocate aligned OS memory directly, fall back to over-allocation #127

@immno

Description

@immno
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

fn main() {
    let mut list = Vec::new();
    for _ in 0..300000000 {
        list.push(DataValue::Double(66.66));
    }
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum DataValue {
    #[default]
    Null,
    Bool(bool),
    Long(i64),
    Double(f64),
    String(String)
}

Using MiMalloc in this scenario will crash the program, using about 8GB of memory, but using std will run fine.

mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x40800000 bytes, address: 0x7FBD9084A000, alignment: 0x2000000, commit: 1)
mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x80800000 bytes, address: 0x7FBD0F800000, alignment: 0x2000000, commit: 1)
mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x100800000 bytes, address: 0x7FBC0D800000, alignment: 0x2000000, commit: 1)
mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x200800000 bytes, address: 0x7FBA0B800000, alignment: 0x2000000, commit: 1)
mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x400800000 bytes, address: 0x7FB609800000, alignment: 0x2000000, commit: 1)
已杀死

How can I optimize it so that there is no OOM when the memory is sufficient? This is a big problem for me. I have a real-time data processing program that processes rdkafka. Sometimes OOM occurs at 3.7GB (the limit is 4GB). Now I have to increase the memory to 8GB to ensure stability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions