'What is the relation between "ulimit -c some_value " (not unlimited) and the core dump size?

My objective is to limit the core dump size to 10MB . I tried experimenting with the soft and hard limits for core. I see the below behavior with different values of ulimit -Sc . The coredump size exceeds the limits set . Can anyone help me to understand why this is the case ?

  1. ulimit -Sc 1000;ulimit -Hc 2000; In this case , the coredump size is 1.6MB .

  2. ulimit -Sc 10240;ulimit -Hc 10240; In this case , the coredump size for the same process is 82MB . Why is this size greater than the limits set ?

I thought the ulimit is specified in kilobytes . If this is right assumption , the coredump size for case 2 above should be max of 10MB .



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source