• Runs indefinitely
• Produces no output
• Consumes an unbounded amount of memory

Specifications

• You must list the implementation used for your program. This is relevant because some implementations might preform optimizations while others do not. For example, the LISP code (defun f () (f)) (f) may or may not consume infinite memory depending on whether the implementation optimizes tail recursion.
• Obviously, your program may terminate from running out of memory.

Examples

BF:

+[>+]


Python:

l = []
while True:
l.append(1)


JavaScript:

l = [];
while (true)
l.push(1);


C (I'm not sure if this works):

#include <stdio.h>
int main() {
while (1)
malloc(1);
}


This is , so the shortest valid solution (in bytes) wins.

marked as duplicate by Dennis code-golf StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Feb 15 '17 at 7:22

• – zeppelin Feb 15 '17 at 7:17
• Depending on how strictly you interpret things: if a C compiler can prove that code has no effect, it can replace it with anything else that also has no effect. So given an arbitrarily smart compiler, it might not be possible to write an infinite C program with no effect. In practice this is hampered by the fact that none of our compilers can solve the halting problem. Also, malloc is in stdlib.h, not stdio.h. – ephemient Feb 15 '17 at 7:21
• @ephemient That's why I forced you to specify the implementation. Also, some compilers will already include <stdlib.h> by default. – Esolanging Fruit Feb 16 '17 at 1:00
• Some compilers will happen to pull in stdlib.h transitively via stdio.h. That doesn't mean they include stdlib.h by default. – ephemient Feb 16 '17 at 2:13

Jelly, 2 bytes

‘ß


Increments and calls itself recursively. As the integer gets bigger, more memory is required to store it.

You can Try it online!, but it's not much to look at.

• Wouldn't this cause stack overflow before your computer runs out of memory? – Pavel Feb 15 '17 at 7:00
• No, Jelly has tail call optimization. This is just a fancy while loop. – Dennis Feb 15 '17 at 7:01

Python 3, 16 bytes

i=9
while i:i*=9


As ints in Python3 are only limited by the memory, this will run until there is no more memory available.

Befunge-98, 1 byte

'


Fills the stack with strings containing '

Java (OpenJDK 9), 75 bytes

interface G{static void main(String[]a){a=new String[1];for(;;)a[0]+=' ';}}


Try it online!

Bash, 17 bytes

for((;;)){ a+=a;}


Try it online!

Brain-Flak, 8 bytes

(()){()}


Try it online!

• Since the {...} monad keeps track of the value of each run, you could simply do (()){[]} or (()){()} instead. – DJMcMayhem Feb 15 '17 at 8:39

Vim, 13 bytes

qqaa<esc>"Ax@qq@q


This defines a macro, q that appends the letter a to the register A and then calls itself. This results in an infinite loop of making register A bigger and bigger, only limited by memory.

• It looks to me like you're missing an <esc> in the macro. This will just output a"Ax@qq@q and exit. – DJMcMayhem Feb 15 '17 at 23:39

Ruby, 15 bytes

i=[];loop{i<<0}