What is the maximum buffer size allowed in memecpy() function in c, I am using GCC compiler,32-bit system, What is the affecting factor for memcpy failure?

->Alignment issue?
->Size?

however the buffer size 256bytes not working, tried 160 bytes copy which fits our requirement

Thanks for the relpy. I went through the webpage but still have a doubt.
On my system size_t is of 4 byte. As it is unsigned so 2^32
= 4294967296. Means this many bits size_t could hold and hence memcpy() can copy only this much size of data ???

To be honest I don't know, and never knew there was a max.

If I needed to know however, I'd probably test it starting with that value. Or just divide and rule.

Best way would probably be to test it out and see for yourself. Close anything important, open your proccess manager, and just keep increasing it until it stops working!

To be honest I don't know, and never knew there was a max.

That's because it's high enough that if you reach it, you're doing something very very wrong. ;)

Sounds about right.

If there no official limit, I'd guess that the max would be the amount of free memory currenly available.

If there no official limit, I'd guess that the max would be the amount of free memory currenly available.

There's an official limit: the range of size_t. Obviously if you cannot tell memcpy to copy more than (size_t)-1 bytes, then that's the limit in a single call. Copying more than that requires multiple calls, but on a modern system size_t is typically either 32 or 64 bits. So the limit is quite large.

Thanks Everyone for the prompt replies.
Ideally size_t should be able to hold quite large amount of memory. I think I need to check the code, may be somewhere something else is going wrong.

Edited 2 Years Ago by ram619

This article has been dead for over six months. Start a new discussion instead.