Created
May 6, 2020 12:57
-
-
Save totem3/4c9c73539857304d673f586dc0a55f6f to your computer and use it in GitHub Desktop.
windowsとlinuxでstack overflowするサイズの比較
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
use std::fs::File; | |
use std::io::{self, Read, Write}; | |
const SIZE: usize = 8000; | |
fn main() { | |
let stack = std::env::var("RUST_MIN_STACK").unwrap_or("nothing".to_string()); | |
println!("RUST_MIN_STACK: {}", stack); | |
println!("allocate size: {}MB", SIZE * 1024 / 1024 / 1024); | |
let x = [[0u8; 1024]; SIZE]; | |
for i in x.iter() { | |
for j in i.iter() {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
linuxは8MBくらい。RUST_MIN_STACKは新しく起動するthreadには影響するけど8MBを超える値を設定してもmain threadのstack sizeが増えるわけではない
windowsは2MBくらい。