Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
14 Views

Zero-initialized memory with scalable_malloc

Hi,

I would like to know if scalable_malloc makes any guarantees about zero-initialized memory (for example: always zero-initialized up to requests for X bytes), whether or not this fact can be queried with the API (as in up to how many bytes this guarantee covers) and if it's going to stay like this in the future.

I need to guarantee zero-initialized memory for a project I'm working on, and it's a waste of precious CPU cycles to zero-initialize something if it's already zero-initialized.

Thanks in advance.

0 Kudos
2 Replies
Highlighted
Employee
14 Views

Hi Jimenez,

TBB Allocator has no any guarantees regarding zero-initialized memory returned by scalable_malloc. However, you can use scalable_calloc instead that is always returns zero-initialized memory.

 

0 Kudos
Highlighted
Beginner
14 Views

Hi Nikita,

That's a very good point. I hadn't seen that function, and it does do what I need. Thanks :)

0 Kudos