Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large stack memory usage #4

Open
occheung opened this issue Jan 6, 2021 · 0 comments
Open

Large stack memory usage #4

occheung opened this issue Jan 6, 2021 · 0 comments

Comments

@occheung
Copy link

occheung commented Jan 6, 2021

Description

With a large MTU / RAW_FRAME_LENGTH_MAX at 0x1000, large amount stack space is consumed. Seems that large arrays are allocated onto the stack on transmitting/receiving packets.
On transmitting case, these few lines of code may have contributed to this issue.

ENC424J600/src/tx.rs

Lines 54 to 60 in 010be3e

impl TxPacket {
pub fn new() -> Self {
TxPacket {
frame: [0; RAW_FRAME_LENGTH_MAX],
frame_length: 0
}
}

ENC424J600/src/lib.rs

Lines 161 to 163 in 010be3e

// Copy packet data to SRAM Buffer
// 1-byte Opcode is included
let mut txdat_buf: [u8; RAW_FRAME_LENGTH_MAX + 1] = [0; RAW_FRAME_LENGTH_MAX + 1];

Shrinking RAW_FRAME_LENGTH_MAX to 1500 have improved this significantly in my case.
Is it worth looking into reusing large arrays? Or even allow static buffers to be supplied by user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant