Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Mem alloc test

Language: Layout:
+ ] Compiler args + ] Show input
Compilation time: 0.25 sec, absolute running time: 0.13 sec, cpu time: 0.05 sec, memory peak: 3 Mb, absolute service time: 0,39 sec 
edit mode |  history  | discussion
Warning(s):
source_file.c: In function ‘main’:
source_file.c:11:20: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
         char * p = malloc(mem_size);
                    ^
source_file.c:11:20: warning: incompatible implicit declaration of built-in function ‘malloc’
source_file.c:11:20: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
source_file.c:14:20: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘size_t {aka long unsigned int}’ [-Wformat=]
             printf("[%3d]:Size = %-20d, Ptr = %p\n", i, mem_size, p);
                    ^
source_file.c:15:13: warning: implicit declaration of function ‘free’ [-Wimplicit-function-declaration]
             free(p);
             ^
source_file.c:15:13: warning: incompatible implicit declaration of built-in function ‘free’
source_file.c:15:13: note: include ‘<stdlib.h>’ or provide a declaration of ‘free’
Error(s):
No memory: Cannot allocate memory
Hello, world!
[  0]:Size = 1                   , Ptr = 0xfc0020
[  1]:Size = 2                   , Ptr = 0xfc0020
[  2]:Size = 4                   , Ptr = 0xfc0020
[  3]:Size = 8                   , Ptr = 0xfc0020
[  4]:Size = 16                  , Ptr = 0xfc0020
[  5]:Size = 32                  , Ptr = 0xfc0040
[  6]:Size = 64                  , Ptr = 0xfc0070
[  7]:Size = 128                 , Ptr = 0xfc00c0
[  8]:Size = 256                 , Ptr = 0xfc0020
[  9]:Size = 512                 , Ptr = 0xfc0020
[ 10]:Size = 1024                , Ptr = 0xfc0020
[ 11]:Size = 2048                , Ptr = 0xfc0020
[ 12]:Size = 4096                , Ptr = 0xfc0020
[ 13]:Size = 8192                , Ptr = 0xfc0020
[ 14]:Size = 16384               , Ptr = 0xfc0020
[ 15]:Size = 32768               , Ptr = 0xfc0020
[ 16]:Size = 65536               , Ptr = 0xfc0020
[ 17]:Size = 131072              , Ptr = 0xfc0020
[ 18]:Size = 262144              , Ptr = 0x7f792e150010
[ 19]:Size = 524288              , Ptr = 0x7f792e110010
[ 20]:Size = 1048576             , Ptr = 0x7f792e090010
[ 21]:Size = 2097152             , Ptr = 0x7f792d9d3010
[ 22]:Size = 4194304             , Ptr = 0x7f792d7d3010
[ 23]:Size = 8388608             , Ptr = 0x7f792d3d3010
[ 24]:Size = 16777216            , Ptr = 0x7f792cbd3010
[ 25]:Size = 33554432            , Ptr = 0x7f792bbd3010
[ 26]:Size = 67108864            , Ptr = 0x7f7929bd3010
[ 27]:Size = 134217728           , Ptr = 0x7f7925bd3010
[ 28]:Size = 268435456           , Ptr = 0x7f791dbd3010
[ 29]:Size = 536870912           , Ptr = 0x7f790dbd3010
[ 30]:Size = 1073741824          , Ptr = 0x7f78edbd3010
Goodbye, world!

    
                
λ
.NET NoSQL database for rapid development