you can allocate as much memory as you want. There is a rumor that "malloc never fails". the thing is malloc doesn't actually map physical frames during allocation. It just return the virtual address to start of the memory in virtual address space.
But when you do memset(), we require physical page frames - it is when system can hang or slow-down due to memory constraints. As underneath OS will try its best to allocate pages based on demand paging and will do numerous swap-in / swap-out of the pages to make a room for this operation in physical RAM. It will first slow down the machine, and eventually hang at later stage.