text:
Shortest program that continuously allocates memory
Write a program which runs forever and allocates more and more memory on the heap the longer it runs, at least until you reach the limit of the operating system on the amount of memory that can be allocated.
Many kernels won't actually reserve memory you allocate until you use it for something, so if your program is in C or some other low level language you'll have to make sure you write something to each page. If you're using an interpreted language, you're probably not going to have to worry about this.
Shortest code wins.

Is a stack overflow a valid solution?  Does the memory have to be leaked or just allocated?

@WheatWizard The memory does not have to be leaked, but it has to be allocated faster than it is deallocated.

The one time I want my program to consume infinite memory, I can't get it to. (reduce conj [] (range)) (Clojure) gets up to 737mb, then just stops growing. Idk how it's not continually going up. It "thinks" I want to print the entire list at the end, so it shouldn't be throwing anything away. Very frustrating.

Note to self: Save code before testing. Introducing mem-leaks might crash IDE...

@steenbergh Ya, happened to me too. At least a 10 bytes solution is easy to rewrite :D

Would a program that computes a googolplex count? It wouldn't run "forever" in the technical sense, but it would use up all the resources of any computer.

@asmeurer I guess so...

I think you should add another golf challenge, similar but separate to this, requiring the program consume memory faster than a linear function of time.  For the current challenge, looping forever and allocating a single byte should be fine.  For your new challenge, that would be insufficient, but looping forever and doubling the amount of memory used each time would be ok.

Funge-98 (cfunge), 1 byte
9

I would have posted this earlier, but decided to test it, and it took a while to get my computer back to a usable state. cfunge stores the Funge stack on the operating system's heap (which is easily verifiable by running the program with a small memory limit, something that I should have done earlier!), so an infinitely growing stack (as with this program, which just pushes 9 repeatedly; Funge programs wrap from the end of a line back to the start by default) will allocate memory forever. This program likely also works in some Befunge-93 implementations.
More interesting:
"NULL #(4

This was my first idea, and is an infinite allocation that doesn't rely on the Funge stack (although it blows up the Funge stack too). To start with, the " command pushes a copy of the rest of the program to the stack (it's a string, and the program wraps round, so the close quote also serves as the open quote). Then the N reflects (it has no meaning by default), causing the program to run backwards. The " runs again, and pushes the program to the stack – the other way round this time, with the N at the top of the stack – then the program wraps around, loading a library with a 4-letter name (4(; the NULL library is part of cfunge's standard library). NULL defines all uppercase letters to do reflect, so the L reflects, the # skips the library load on the way back, the 4 pushes junk we don't care about to the stack and the whole program repeats from the start. Given that loading a library multiple times has an effect, and requires the library's command list to be stored once for each copy of the library (this is implied by Funge-98's semantics), it leaks memory via non-stack storage (which is an alternative method of defining "heap", relative to the language rather than the OS).

I'm just going to accept this...

Is it necessary for the number to be 9? Would it also work if it was 5?

Anything that pushes to the stack works (except possibly 0; it's possible that the Funge implementation or the OS could find a way to optimize that out, given that the memory in question is full of zeroes already). I just picked 9 arbitrarily.

Unaccepting because I want my reputation to still be 666.

@tbodt Not a real reason to not accept. If you'd like, I'll -1 your question. Then when you accept, you'll have 703 still (note you have 703 now, not 666).

Wouldn't "LLUN"4( also have the same intended effect as the second program, for one less character and a lot less complexity?

@immibis: Yes. The original was "NULL(4, but it didn't work because I forgot what NULL did. (Perhaps some other library would work; it'd need to define fairly benign commands corresponding to the letters of its name. I might look into that when I'm less tired.) I edited it into a working version to leave the answer mostly the same without being wrong.

@ais523 Notice that I put quote marks on both sides of the name, this is a typical string literal, its contents don't get interpreted as commands. (Also I don't remember whether it needs to be "NULL" or "LLUN" and I can't be bothered looking it up)

Brainfuck, 5 bytes
+[>+]

This requires an interpreter that has no limit on the length of the tape.

I'm pretty sure it's +[>+] or else it would simply stop at the first iteration. ;)

You are right, sorry for the typo.

One of the rare times where a brainfuck solution is competitive...

@Flp.Tkc But it still loses. Maybe it will win someday...

@SeeOneRhino : It already won once, beating all golfing languages> http://codegolf.stackexchange.com/questions/8915/write-a-program-that-uses-all-printable-non-alphanumeric-ascii-symbols/8926#8926

Bash + coreutils, 5
or
Ruby, 5
`yes`

yes produces endless output.  Putting yes in backticks tells the shell to capture all output and then execute that output as a command.  Bash will continue allocating memory for this unending string until the heap runs out.  Of course the resulting output would end up being an invalid command, but we should run out of memory before that happens.
Thanks to @GB for pointing out this is a polyglot in ruby too.

I was about to write the same and call it a Ruby program.

and perl, I think.

Python, 16 bytes
Keeps nesting a until an error is reached:
a=0
while 1:a=a,

The first few iterations (as tuples) look like this:
0
(0,)
((0,),)
(((0,),),)

and so on and so forth.

><> (Fish), 1 byte
0

Try it here!
0 can actually be substituted for any hexadecimal number 1-f.
Explanation
0 in ><> simply makes a 1x1 codebox for the fish to swim in. It constantly adds a 0 onto the stack, swims right, which loops backaround to 0, adding it to the stack again. This will go on forever.

Now I'm wondering how many other 2-dimensional languages this works in. Most of them are stack-based, after all.

Almost works in Cubix, but it requires a leading . (or any non-whitespace char) to move the 0 into the line of execution.

Works in Ouroboros, but not in the same way: The interpreter tries to read 0000000... as a single integer literal, and the string that it builds up is what keeps taking more memory. A program that works the way this one does would be a (pushes 10 infinitely).

Perl, 12 bytes
{$"x=9;redo}

In perl, the x operator, with a string on the left and a number on the right, produces a repeated string.  So "abc" x 3 evaluates to "abcabcabc".
The x= operator mutates the left argument, replacing contents of the variable on its left with the result of repeating it's contents as many times as its right hand side indicates.
Perl has a number of a number of strangely named built in variables, one of which is $", whose initial value is a single space.
The redo operator jumps to the beginning of the enclosing {}.
The first time the x= operator is done, it changes the value of $" from " "" to "         ", which is 9 spaces.
The second time the x= operator is done, it changes the value of $" to "                                                                                ", which is 81 spaces.
The third time, $" becomes a 729 byte long string of spaces.
I think you can see where this is going :).

You beat me to it!  And yours is three bytes shorter.

It was just a matter of searching this web site for the smallest loop :).  Also, I'd initially has $_.=7 in my loop, but realized if I could use x= it would run out of memory much much faster, and then ran perldoc perlvar to pick something suitable.

{$^O++;redo} is one byte shorter when ^O is a single chr(15) byte. Though it will waste memory at MUCH slower rate - 1000000000 iterations are required on Windows to waste one byte. Will work on any OS that have its name starting in Latin letter.

Java 101 bytes
class A{public void finalize(){new A();new A();}public static void main(String[]a){for(new A();;);}}

Catching main Program in a endless Loop after creating and throwing away a object. Garbage collection does the job of leaking by creating 2 objects for each deleted ones

well I feel a little silly for not going with the obvious now, haha. I'd venture to say this is more elegant than mine

yeah, your code remembered me to that fact with the finalize() @poke

I think you could make it shorter by replacing main with a static initializer

only works up to java6 and i only got higher versions around

see my 81 byte answer ;)

haha using the garbage collector to cause a leak!  great idea :)

Relying on finalize() is a bad idea

endless loop prevents exit of program though @Snowman

sed, 5 bytes
Golfed
H;G;D

Usage (any input will do)
sed 'H;G;D' <<<""

Explained
#Append a newline to the contents of the hold space,
#and then append the contents of the pattern space to that of the hold space.
H

#Append a newline to the contents of the pattern space,
#and then append the contents of the hold space to that of the pattern space.
G

#Delete text in the pattern space up to the first newline,
#and restart cycle with the resultant pattern space.
D

Screenshot

Try It Online !

Strictly speaking this is GNU sed (semicolon is not standard sed) but a newline would work just as well as the semicolon anyway.

Haskell, 23 19 bytes
main=print$sum[0..]

Print the sum of an infinite list

This is a nice way to enforce evaluation, and it's very compact too. +1

a compiler could very well run this in O(1) memory. In GHC, sum is defined as foldl (+) 0, and what's to stop the strictness analysis to kick in, to prevent the thunk blow-out? Did you run it compiled with optimizations?

@WillNess What could the answer be? sum won't know in advance that the list is infinite and to print the sum it must be evaluated first. And yes, I compiled it with optimizations

there wouldn't be an answer; but the calculation would run in O(1) space. Oops, strike that, because of the defaulting to Integer, the numbers are unbounded and the memory taken by the bignum current result, would indeed grow.

just to clarify, what I meant was that the calculation of sum xs = foldl (+) 0 xs can run in constant stack, as any imperative loop would. foldl' (+) 0 xs certainly will. So the only thing allocating memory for certain, is the bignum interim result.

@WillNess If that's true, this must be one of the least efficient allocators of memory ...

@DepressedDaniel all the answers to this question are something a sufficiently smart compiler could detect and stop or optimize away.

C++ (using g++ compiler), 27 23 15 bytes
Thanks to Neop for helping me to remove 4 bytes
This solution does not really leak any memory because it allocates everything on the stack and thus causes a stack overflow.  It is simply infinitely recursive.  Each recursion causes some memory to be allocated until the stack overflows.
main(){main();}

Alternative solution
This solution actually leaks memory.
main(){for(;;new int);}

Valgrind output
This is the Valgrind output after terminating the program several seconds into the run time.  You can see that it is certainly leaking memory.
==2582== LEAK SUMMARY:
==2582==    definitely lost: 15,104,008 bytes in 3,776,002 blocks
==2582==    indirectly lost: 0 bytes in 0 blocks
==2582==      possibly lost: 16 bytes in 4 blocks
==2582==    still reachable: 4 bytes in 1 blocks
==2582==         suppressed: 0 bytes in 0 blocks

The title is misleading; the question says to "write a program which runs forever and continuously allocates memory."

Oh I did not realize you already submitted an answer when I sent mine.

@Neop Well I didn't know you could ommit the int  until I saw your's so thanks!

Which compiler accepts this implicit int syntax? (doesn't work in MS Visual Studio)

@anatolyg I am using g++.

Not C++, just the g++ dialect of it: C++ forbids calling main; C++ requires int main... declaration. But the solution is still neat :-)

Indeed, C++ forbids calling main.

///, 7 bytes
/a/aa/a

Constantly replace a with aa, ad nauseum.

*aad naauseum

ad nauseam => aad naauseaam

What about //a/? That seems to forever replace `` (nothing) by a, but not sure if this is exactly specified.

JAVA, 81 79 78 bytes
JAVA (HotSpot) 71 70 bytes
Shorter than other Java answers at the time I posted (81, later 79 bytes):
class A{public static void main(String[]a){String x="1";for(;;)x+=x.intern();}}

As suggested by @Olivier Grégoire, a further byte can be saved:
class A{public static void main(String[]a){for(String x="1";;)x+=x.intern();}}

Placing x+=x.intern() as the for loop increment would not help anything, because a semicolon is still required to end the for statement.
As suggested by @ETHproductions, just using x+=x works too:
class A{public static void main(String[]a){String x="1";for(;;)x+=x;}}

Which can also benefit from @Olivier Grégoire's tip:
class A{public static void main(String[]a){for(String x="1";;)x+=x;}}

My only misgivings about that is that it is not guaranteed to allocate data on the heap, as an efficient JVM can easily realize that x never escapes the local function. Using intern() avoids this concern because interned strings ultimately end up stored in a static field. However, HotSpot does generate an OutOfMemoryError for that code, so I guess it's alright.
Update: @Olivier Gregoire also pointed out that the x+=x code can run into StringIndexOutOfBoundsException rather than OOM when a lot of memory is available. This is because Java uses the 32-bit int type to index arrays (and Strings are just arrays of char). This doesn't affect the x+=x.intern() solution as the memory required for the latter is quadratic in the length of the string, and should thus scale up to on the order of 2^62 allocated bytes.

Welcome to PPCG! I don't know Java very well; what would happen if you just did x+=x;?

you can shave a semicolon off by putting the x+=x.intern() behind the last semicolon of the for loop

Nice answer. I knew there had to be something with string interning but I was pretty happy with Unsafe and finalize that I stopped looking, haha. Originally this question specified "memory leak" which is why I didn't just do a string concat answer.

If your answer depends on a specific implementation of Java, and wouldn't necessarily be portable to all Java implementations, you can place the information in the title (e.g. # Java (HotSpot), 71 bytes). That way, you don't need to worry about the solution potentially cheating; implementation-specific programs are common not just in golfing, but in the wider world of programming too, and as long as you're aware of what you're doing may sometimes be more appropriate than a portable program for, say, a one-off script.

for(String x="1";;x+=x); to save 1 byte.

humm... x+=x; doesn't exhaust the whole memory. With 64 GB, I get an StringIndexOutOfBoundsException, not an OOM. With .intern() I still get the OOM.

couldn't you save a lot of space by replacing main with a static initializer?

@tbodt That just results in a "Main method not found in class" runtime error.

I think it works on old versions of java (like java 6), you could specify that the program only works on java 6

@tbodt Don't have an easy way to test the claim that it works on java 6.

I'm going to dig up an old version of the jdk and test this when I have time...

interesting, infinite loops aren't allowed in static initializers. so it doesn't really matter...

@tbodt What about class A{static{for(String x="1";(x+=x.intern())==x;);}}?

Perl 6, 13 bytes
@= eager 0..*

Explanation:
@ = store the result into an unnamed array
eager make the following list eager
0 .. * infinite range starting at zero

Python 3, 16 bytes
i=9
while 1:i*=i

This comes from the fact that there is no limit to integer size in Python 3; instead, integers can take up as much memory as the system can handle (if something about my understanding of this is wrong, do correct me).

The title implies that the memory should be leaked.  But this doesn't actually leak memory.  The author should probably clarify.

Rust, 46 bytes
fn main(){loop{std::mem::forget(Box::new(1))}}

Notice something interesting about this Rust program, leaking heap allocations until out of memory?
That's right, no unsafe block. Rust guarantees memory safety in safe code (no reading of uninitialized data, read after free, double free etc.), but memory leaks are considered perfectly safe. There's even an explicit function to make the compiler forget about RAII cleanup of out of scope variables, which I use here.

TI-83 Hex Assembly, 7 bytes
PROGRAM:M
:AsmPrgm
:EF6A4E
:C3959D
:C9

Creates appvars indefinitely until an ERR:MEMORY is thrown by the OS. Run with Asm(prgmM). I count each pair of hex digits as one byte.

Python, 8 bytes
2**9**99

The OP has allowed the technicality of a program that doesn't technically run "forever", but allocates more memory than any computer could possibly handle. This isn't quite a googolplex (that would be 10**10**100, 11 bytes), but naively, log base 2 of the number is
>>> 9**99.
2.9512665430652752e+94

i.e., 10^94 bits to represent it. WolframAlpha puts that as 10^76 larger than the deep web (keep in mind that there are about 10^80 atoms in the universe).
Why 2 instead of 9 you ask? It doesn't make much of a difference (using 9 would only increase the number of bits by a factor of log2(9) = 3.2, which doesn't even change the exponent). But on the other hand, the program runs much faster with 2, since the calculation is simpler. This means it fills up memory immediately, as opposed to the 9 version, which takes a little longer due to the calculations required. Not necessary, but nice if you want to "test" this (which I did do).

Jelly, 3 2 bytes
-1 byte thanks to Dennis (W wraps)
Wß

A link (i.e. function or method), which also works as a full program, that recursively wraps its input into a list.
The input starts as zero so the first pass creates the list [0]
The second pass then makes this [[0]]
The third pass then makes this [[[0]]]
and so on...

Previous 3 byter, which leaks much faster:
;Ẇß

recursively concatenates all non-empty contiguous sublists of its input to its input.
[0] -> [0,[0]] -> [0,[0],[0],[[0]],[0,[0]]] and so on...

If I understand the rules correctly, ‘ß should be plenty.

Does that really "continuously allocate memory" (thinking about Python keeping constant allocation for small ints).

Fair enough. Wß should still fit the bill though.

C (linux), 23 bytes
main(){while(sbrk(9));}

sbrk() increments the top of the data segment by the given number of bytes, thus effectively increasing the amount of memory allocated to the program - at least as reported in the VIRT field of top output.  This only works on Linux - the macOS implementation is apparently an emulation that only allows allocation of up to 4MB.

So a slightly more general answer:
C, 25 bytes
main(){while(malloc(9));}

I watched it on the macOS Activity Monitor.  It went all the way up to about 48GB, then eventually the process received a SIGKILL signal.  FWIW my macbook pro has 16GB.  Most of the memory used was reported as compressed.
Note that the question effectively requires each allocation to be written to, which doesn't happen explicitly here.  However it is important to note that for every malloc(9) call, it is not just the 9 user requested bytes that are allocated.  For each block allocated there will be a malloc header that is also allocated from somewhere on the heap, which is necessarily written to by the malloc() internals.

With malloc, you are not directly writing in the memory since malloc does not initialise anything.
The memory is only allocated because malloc needs some internal storage for memory managing. So the answer isn't really standard but I guess it works everywhere anyway.

@Antzi Yes.  However, I think this still works though because even though the user memory might not actually be allocated before it is written to, each malloc()ed block must still have its own real allocated space.  This works on macOS and Ubuntu.

The condition in the question of each page being written to is rather meaningless; even if you want to assume an OS does not do proper commit accounting, regardless of implementation details there is necessarily a nonzero amount of bookkeeping needed per allocation. Whether it is adjacent to the allocation (causing pages to be touched) or not, it will eventually consume arbitrarily amounts of memory for bookkeeping with (necessarily) nonzero data.

You could get it one byte smaller as main(){main(malloc(9));}, but in order not to stack overflow, it needs tail call optimization, and gcc doesn't seem to want to do that on main...

If you replace malloc(9) with calloc(9,9) then there will be enough memory allocated for 9 instances of a 9-byte block (so between 81 and 144 bytes, depending on alignment.
However, and more importantly, calloc() will zero-fill the block of memory, forcing the underlying OS to allocate storage to it.

Java 7, 106 bytes
class A{public void finalize(){for(;;)Thread.yield();}public static void main(String[]a){for(;;)new A();}}

Less Golfed
class A{
    @Override
    public void finalize(){
        for(;;) {
            Thread.yield();
        }
    }
    public static void main(String[]a){
        for(;;){
            new A();
        }
    }
}

The finalize method is called on an object by the garbage collector when garbage collection determines that there are no more references to the object. I have simply redefined this method to loop forever so the garbage collector never actually frees the memory. In the main loop I create new objects which will never be cleaned up so eventually this will use up all the available memory.
Java 7 (fun alternative), 216 bytes
import sun.misc.*;class A{public static void main(String[]a)throws Exception{java.lang.reflect.Field f=Unsafe.class.getDeclaredField("theUnsafe");f.setAccessible(1>0);for(;;)((Unsafe)f.get(null)).allocateMemory(9);}}

Less Golfed
import sun.misc.*;
class A{
    public static void main(String[]a)throws Exception{
        java.lang.reflect.Field f=Unsafe.class.getDeclaredField("theUnsafe");
        f.setAccessible(true);
        Unsafe u = (Unsafe)f.get(null);
        for(;;) {
            u.allocateMemory(9);
        }
    }
}

This is a fun one more than anything else. This answer makes use of the Unsafe Sun library which is an undocumented internal API. You may need to change your compiler settings to allow restricted APIs. Unsafe.allocateMemory allocates a specified amount of bytes (without any boundary checking) which is not on the heap and not under java's garbage collector management so this memory will stick around until you call Unsafe.freeMemory or until the jvm runs out of memory.

Was wondering if I'd see Java here.

Doesn't the first one only work if the garbage collector is running in a separate thread?

@tbodt yes but i don't believe this is ever not the case. Garbage collection happens in a daemon thread called garbage collector

@Poke is that guaranteed? if not the answer is still fine, but you should clarify that it only works if the garbage collector runs in its own thread

@tbodt I think so but I'm not certain, honestly.

see my 81 byte answer ;)

Haskell, 24 bytes
f x=f$x*x
main=pure$!f 9

The main problem in Haskell is to beat the laziness. main needs to have some IO type, so simply calling main=f 9 would not work. Using main=pure(f 9) lifts the type of f 9 to an IO type. However using constructs like main=pure 9 does not do anything, the 9 is returned or displayed nowhere but simply discarded, so there is no need to evaluate the argument of pure, hence main=pure(f 9) does not cause any memory to be allocated as f is not called.
To enforce evaluation, the $! operator exists. It simply applies a function to an argument but evaluates the argument first. So using main=pure$!f 9 evaluates f and hence continuously allocates more memory.

When compiled, the runtime detects the loop and breaks execution

@Angs I compiled with ghc on windows and it keeps happily allocating memory ... I stopped it at 3GB.

Using f x=f x works too, right? (−2 bytes)

@wchargin I don't think so, f x=f x produces an infinite loop, but without allocating new memory.

Nice, causing the memory blow-out by the bignum calculations! f!x=x*f(x*x) should make it optimizations-proof.

Haskell (using ghc 8.0.1), 11 bytes
m@main=m>>m

Non-tail recursion. main calls itself and then itself again.

Does this allocate on the heap or the stack? (I can believe either; it may well depend on the Haskell compiler in uses.)

@ais523: it depends. Haskell has no call stack. The run time system RTS has a memory area for pattern matching which is also called "stack". This stack is allocated on the heap. Honestly, I don't know what's going on here, because the program fails with Stack space overflow: current size 33624 bytes. 33k seems quite low in contrast to the 6G of total memory that the OS is reporting.

@ais523: there seems to be a bug in the memory information of the ghc error message, so it's hard to tell what exactly happens.

Compiled on GHC 7.10.3 on Ubuntu, this seems takes a constant amount of memory even when optimizations are disabled

@Angs: hmm, I use ghc 8.0.1 on MacOS. I'll edit this in.

dc, 7 bytes
[ddx]dx

[ddx] pushes a string containing "ddx" to the stack. dx duplicates it then executes it as code (leaving one copy on the stack). When executed, it makes two duplicates then executes one, leaving one more copy on the stack each time.

Wait, so this would exponentially allocate the memory if it could run in parallel?

Perl, 4 bytes
do$0

Executes itself, in the current interpreter. When finished, execution returns to the calling script, which requires a call stack.

Nice and short, though it doesn't waste memory quickly as mine.

Racket, 13 bytes
(let l()(l)1)

I'm not entirely certain if my answer falls under this question. Please let me know if I should remove this answer.

Can you explain how it works?

oh, so it's defining l as a function that does non-tailcall recursion. i'd say it counts.

@tbodt yes you're right on the money

JavaScript 22 21 17 16 15 Bytes
for(a=0;;)a=[a]

Saved 4 bytes by wrapping the list in another list as in @Jonathan Allan's Jelly answer.
Saved 1 byte thanks to @ETHProductions
Alternative solution 15 Bytes (only works with proper tail calls)
f=a=>f([a]);f()

On your 2nd example with ES6, couldn't you just do f=_=>f();f() ? 12 bytes

@bitten I am not sure. If it counts to blow the call stack, then that one without proper tail calls would be the way to go. With TCO, I don't think there would be any memory leaked, would there?

both blow the call stack for me. i'm not really familiar with tail calls so i can't comment on that.

ah i see, i wasn't sure how yours was leaking memory

You could remove a=0. First iteration would result in a=[undefined]

@Florent I think that should throw a ReferenceError as a is not declared (i.e. var a is missing), shouldn't it?

@Lmis only in strict mode.

05AB1E, 2 bytes
[A

Try it online!
Will just keep pushing abcdefghijklmnopqrstuvwyxz onto the stack for eternity.
All possible 2-byte solutions:
[  # Infinite loop.
 A # Push alphabet.
 0 # Push 0.
 1 # Push 1.
 2 # Push 2.
 3 # Push 3.
 4 # Push 4.
 5 # Push 5.
 6 # Push 6.
 7 # Push 7.
 8 # Push 8.
 9 # Push 9.
 T # Push 10.
 X # Push 1.
 Y # Push 2.
 ® # Push -1.
 ¶ # Push \n.
 º # Push len(stack) > 0, so 0 once then 1 for eternity.
 ð # Push a space.
 õ # Push an empty string.
 ¾ # Push 0.
 ¯ # Push [].
 M # Push -inf.
 ) # Wrap current stack in an array.

Very thorough! Nice.

Ruby, 11 bytes
loop{$*<<9}

Keeps pushing 9 onto $*, which is an array initially holding the command line arguments to the Ruby process.

Python, 35 bytes
def f(a=[]):a.append(a)
while 1:f()

a is never released and just gets bigger until you hit a MemoryError
You can view the execution on Python Tutor.

Can you do a+=a,?

No need for a function, here's my golf of it

@Flp.Tkc the question was changed after I wrote this answer I would have done what you did (+- couple of characters) if it was in its current format.

Python REPL, 13 bytes
9
while 1:_*9

The first line, 9, sets the built-in _ (last-integer) variable to 9. The infinite loop then keeps setting this to itself multiplied by 9.
Python integers have no upper limit, so this will keep growing until MemoryError.
This only works in the shell, where the _ variable is available. This is allowed by meta.

I don't think the REPL is allowed.

@Pavel http://meta.codegolf.stackexchange.com/a/7844/60919

PHP, 14 13 bytes
Saved a byte thanks to Alex Howansky
while($a.=1);

Indefinitely builds a string of 111111111111...

Which bizarre quirk of php does this exploit?

@tbodt $a[]=1 evaluates to something truthy so the while() loop equates to while(true) and just keeps looping and adding elements to the $a array. Not sure if this can be classified as a quirk though. Is identifying a quirk a requirement of your question? Would you like me to deconstruct my answer into multiple lines?

@tbodt Try it out at http://sandbox.onlinephpfunctions.com/

You can chop a byte with while($a.=1); -- just build a huge string versus a huge array.

while($a.=1); indefinetely adds characters to a string.

Didn't know that $a[] = x adds an element to an array in PHP. I would classify that as a bizarre quirk since I don't know of any other language that does that.

Also note that $a is never declared, and starts with a value of NULL. By assigning a value with square brackets $a[]=, you're implicitly casting NULL to an empty array, and then appending a value.

@tbodt It's actually a well-known language construct and PHP is definitely full of fun little surprises :-)

TI-BASIC, 8
:Lbl A
:While 1
:Goto A

(all 1-byte tokens, and two newlines)
This continuously leaks memory because structured control flow such as While anticipated being closed by an End and pushes something on the stack (not the OS stack, a separate stack in heap memory) to keep track of that. But here we're using Goto to leave the loop (so no End is executed to remove the thing from the stack), the While is seen again, the thing gets pushed again, etc. So it just keeps pushing them until you get ERR:MEMORY

Mathematica,  16 bytes
For[i=0,0<1,i++]

Endlessly adds 1 to an arbitrary precision integer, causing its representation in memory to slowly grow.
Might also be the slowest submission since memory allocated only grows logarithmically with time.  In fact, I've only let it run to several hundred billion, which barely alters allocated memory.  So how do I know it grows without bound?  Try the variant
For[i = 1, 0 < 1, i += i]

so that the memory usage is now linear in time...  (If you want to watch i,
Monitor[For[i = 1, 0 < 1, i += i], i]

and notice, for instance, that the front end is allocating memory to hold the displayed values faster than the kernel is, because the binary representation is much less fluffy that the decimal representation and resulting graphical object.  I suppose one could stress test one's 2D video acceleration by switching to the console interface and running the Monitor[] there...  Heh.)

BASH, 2 bytes
$0

Parameter $0 is the filename of the script, so it will call itself forever.

This starts new processes repeatedly, instead of allocating memory in a single process, so I would say it doesn't count.

It could theoretically work on an operating system where processes share the heap with each other (some variants of uclinux, perhaps; DOS has a shared heap in 16-bit mode but I don't know that it has a bash implementation)? I don't think this can be valid without specifying an OS where it works, though. (Also, the process limit may be hit before the memory limit is.)

I think $0|$0 works, but it's longer.

$0 $@$$& if you really wanted to kill your system, whilst not using compressed RAM.

Microscript II, 3 bytes
1[s

Rough translation:
x=1
while x
  push x

Ceylon, 55 54 35 bytes
shared void r(){variable Object x=0;while(0<1){x=[x];}}

This is a simple while loop, which creates a one-element tuple containing the previous value, i.e. an ever-growing linked list.
I get an OutOfMemoryError (with the default JVM settings on my computer) after:
real    5m42.727s
user    21m31.200s
sys     0m3.472s

5m42s (using 21 minutes of processor time, says time).
Even shorter is the "functional" approach (which in effect does exactly the same):
shared void r(){loop<Object>(0)((x)=>[x]).each(noop);}

Unfortunately I need the type parameter here, otherwise Ceylon assumes Integer (which is the type of 0) and complains that [0] is not an Integer.
The second version is much slower (I've let it run overnight):
real    197m26.677s
user    770m9.300s
sys     1m23.744s

A different approach is just filling a really big sequence of integers:
shared void r(){max((1:9^9)*.not);}

1:9^9 is a Measure<Integer> (an Iterable containing 9^9 elements, starting with 1), by itself not having lots of memory (just the two numbers). But the *.not attribute spread creates a big ArraySequence with the value of i.not for each element of the Iterable. We need to do something with the result (otherwise the compiler complains that this is not a statement), therefore the max(...). The max function is never called here, because this gives an OutOfMemoryError (with "GC overhead limit exceeded") after 6 minutes while trying to build and fill the array:
real    6m23.948s
user    23m46.956s
sys     0m5.200s

SMBF, 5 bytes
Although the brainfuck solution also works in SMBF, I decided to create a solution that only works in SMBF.
<[>+]

Since the source is placed on the tape to the left of the pointer, < will move the pointer to point at ], and then we loop, traveling forever on the tape.

WinDbg, 9 bytes
as/c a z1

This works by creating a string of infinite length. as /c Sets an alias (here called a) to the result of the following command(s): z 1 is an infinite do while loop that also prints a line when the while condition is true: redo [###] {redone_code}. So a will be set to a string like:
redo [1] z1
redo [2] z1
redo [3] z1
.
.
.
redo [23489723984] z1
.
.
.

SAS, 75 19
SAS doesn't really lend itself to golfing but I thought I'd have a go, and at least it beats Java some of the Java answers quite a lot of stuff, actually.
Original submission:
data;dcl hash h();h.definekey('i');h.definedone();a:i+1;h.add();goto a;run;

This creates a hash object and keeps adding new values to it until SAS runs out of memory. None of the hash operations fail prior to that point, so no need to capture any pesky return codes for them. SAS does have do loops, but goto saves a few characters.
New submission:
%macro a;%a%mend;%a

Much simpler - a trivial recursive macro. If left running for long enough, it eventually fails with an out of memory error. Both submissions assume that SAS was invoked with option memsize = 0, otherwise it will instead fail when it hits that limit if it is lower than the available system memory.

Actually, 3 bytes
1W1

Try it online!
This is an infinite loop that pushes a 1 to the stack each time it runs. Actually is implemented in Python, and its stack is a deque, so, despite the name, all memory is dynamically allocated on the heap.

Labyrinth, 1 byte
_

This keeps pushing a 0 to the stack.

Brain-Flak, 10 bytes
(()){(())}

Try it online!

In the Ruby Brain-Flak interpreter just (()){()} Will actually work.  This is because the Brain-Flak interpreter stores a unbounded variable called @current_value that is incremented by (). Each run of the loop will do nothing visible but will increment that value.  As the value grows the program will allocate more and more memory.

V, 2 bytes
òé

You can try it online, even though it won't output anything.
This simply fills up the interal "buffer" with the ÿ character (0xFF) until the end of time.

C#, 109 bytes
public class P{static void Main({for(;;)System.Xml.Serialization.XmlSerializer.FromTypes(new[]{typeof(P)});}}

Cross posted from here because it answers this question nicely as well.
We found the idea behind this leak in production code and researching it leads to this article. The main problem is in this long quote from the article (read it for more info):

Searching my code for PurchaseOrder, I find this line of code in page_load of one of my pages XmlSerializer serializer = new XmlSerializer(typeof(PurchaseOrder), new XmlRootAttribute(“”));
This would seem like a pretty innocent piece of code. We create an XMLSerializer for PurchaseOrder. But what happens under the covers?
If we take a look at the XmlSerializer constructor with Reflector we find that it calls this.tempAssembly = XmlSerializer.GenerateTempAssembly(this.mapping, type, defaultNamespace, location, evidence); which generates a temp (dynamic) assembly. So every time this code runs (i.e. every time the page is hit) it will generate a new assembly.
The reason it generates an assembly is that it needs to generate functions for serializing and deserializing and these need to reside somewhere.
Ok, fine… it creates an assembly, so what? When we’re done with it, it should just disappear right?
Well… an assembly is not an object on the GC Heap, the GC is really unaware of assemblies, so it won’t get garbage collected. The only way to get rid of assemblies in 1.0 and 1.1 is to unload the app domain in which it resides.
And therein lies the problem Dr Watson.

Running from the compiler in Visual Studio 2015 and using the Diagnostic Tools Window shows the following results after about 38 seconds. Note the Process memory is steadily climbing and the Garbage Collector (GC) keeps running but can't collect anything.

Pushy, 3 bytes
1$a

Just keeps pushing to the stack...
1     % Push 1
$     % While last item != 0 (forever):
a     %   Push char-codes of the lowercase alphabet

This is just one example: several 3 byte solutions exist, such as 1$1, 1$&, 9$9, etc - anything that will "infinitely" push to the stack.

tinylisp repl, 12 bytes
(d f(q(L(f L

Defines a function f that will keep allocating memory when called. If submissions must be full programs, here's a 15-byte solution:
((v(d f(q(L(f L

Explanation
The repl supplies missing parens at the end of the line, so the code is really (d f(q(L(f L)))).
(d f(q(...))) defines f to be the unevaluated list (...). In tinylisp, functions are simply two-element lists. The first element is the parameter list and the second is the function body. Here, the first element is L, which (because it's not wrapped in parentheses) makes this a variadic function in which the entire argument list is assigned to L. The function body (f L) simply calls f again with L as its argument.
This is tail recursion, so the call stack doesn't come into play. But notice what happens to L on successive calls:
(f)        Called with no arguments; L gets empty list ()
(f ())     Called with one argument, empty list; L gets (())
(f (()))   Called with one argument, (()); L gets ((()))

And so on, wrapping the argument in another layer of list each time.

Dyalog APL, 4 bytes
⊂⍣≡⍬

⊂ enclose
⍣ until
≡ identical to the previous iteration (i.e. never, as each iteration has one more level of enclosure)
⍬ empty (numeric) list
The program starts as follows:
[], enclose that, yielding
[[]]. Is that identical to []? No, so we enclose that, yielding
[[[]]]. Is that identical to [[]]? No, so we enclose that...
Since each enclosure needs a new pointer, memory usage will slowly increase until WORKSPACE FULL.

I've already learned Lisp and Prolog, I should learn APL now

@tbodt Can I help you get started?

sure, got any nice links?

@tbodt First, get the full version of Dyalog APL, and while you wait for your license to arrive, have a look at the "Learn" tab of tryapl.org. The book Mastering Dyalog APL is a must. If you don't want to pay, you can just download the PDF for free.

@tbodt Make sure to check out #onelinerwednesday and YouTube. Use Twitter, Facebook, or visit the forums or send me an email if you get stuck or have questions.

PowerShell, 14 bytes
for(){$i+="z"}

Infinite loop creates a variable(string) and appends new characters to the end. Unbearably slow, took over an hour to consume two megabytes. Verified it would consume all the RAM available using something a bit faster:  for(){$i+=("z"*9MB)}

Since .NET strings are just char[] in the background, you could use an array and do for(){$i+=,1} to save a byte.

Fission, 3 bytes
RX+

Continuously creates atoms and increments its mass.
Try it online!
R                 creates an atom moving right
 X                clones atom, one keeps moving to the right, the other gets reflected left
  +               increment the atom's mass

Because of wrapping, this program will continuously create atoms with non-negative mass
Another alternative:
RX'

R and X works like you expect it to, and ' sets the atom's mass to the ASCII value of the next character it hits, ie 'R' (because of wrapping). Thus, this continuously creates atoms with the ASCII value of 'R'.

Java, 127+19=146
Golfed:
import java.util.*;class A{public static void main(String[]q){List l=new LinkedList();for(;;){String s="";for(int i=0;i>-1;++i)s+=' ';l.add(s);}}}

Ungolfed:
import java.util.*;

public class A {
  public static void main(String[] args) {
    List<String> l = new LinkedList<>();
    for (;;) {
      String s = new String();
      for (int i = 0; i > -1; ++i) {
        s += ' ';
      }
      l.add(s);
    }
  }
}

This program does not rely on the garbage collector or finalize() method like the other Java answers do. Java only interns and merges strings that are constructed from literals, unless specifically interned. That means this program will end up creating strings of size 231 essentially forever, assuming LinkedList works as expected.

You must have missed by answer based on explicitly interning Strings. Also, you can put just l.add(l) in the for loop to save a lot of bytes, and create the loop in the for initializer to get down to 103 bytes.

@DepressedDaniel I must have missed your answer. I saw several Java answers but they were all focused on the garbage collector. And you are right - by using raw types I can make this more efficient. I'll take a look later. Thanks for the tips.

You can replace s+=' ';l.add(s); with l.add(s+=' ');

SmileBASIC, 18 bytes
@L
A$=A$+@A
GOTO@L

Keeps creating strings consisting of @A@A@A....
It would be much faster to use PUSH to modify the original string, but that would use more characters.

The old versions of A$ probably get garbage-collected. This technically does continuously allocate memory but it would be more spectacular if it crashed eventually :)

There's no way to avoid SB's garbage collector, it's way too reliable.

You could PUSH an array until you get Out of memory but that would in fact be longer.

√ å ı ¥ ® Ï Ø ¿ , 3 bytes
(1)

Explanation
(   › Start an infinite loop
 1  › Push 1 to the stack
  ) › End an infinite loop

C, 10 bytes
f(x){f();}

The x is needed for memory to be used in addition to stack space. This will endlessly make calls to itself each time taking ~32bits to store x.

OIL, 12 bytes
Here in annotated form (remove anything but numbers to run):
1 # copy
-1 # from line -1 (containing, by default, a 0)
6 # to line 6 (the first line after the last line) %
8 # increment
2 # line 2 (marked with %)
6 # goto (since the next line will now be 0, go to line 0)

Even though seemingly nothing changes (lines are 0 by default and are being set to 0), internally, there's a difference between an unallocated line and a line with an explicit 0 in it.

Aceto, 2 bytes
e>

Pushes e (2.71..) on the stack, and moves the IP back to the first cell.
There are of course many 2-byte solutions in Aceto, (any single character literal (1234567890ePR'), followed by a command that makes the thing infinite (I can think of <>O, but there might be more), but I chose e> because it looks a bit like a heart (<3 sadly doesn't work).

Rust, 35 31 bytes
-4 bytes thanks to madlaina (into_raw -> leak)
||loop{Box::leak(Box::new(0));}

Try it online
Full program, 40 bytes
fn main(){loop{Box::leak(Box::new(0));}}

Try it online
Unlike the other Rust solution, this uses Box::leak to leak the boxed value, turning it into a &'static mut i32.

Box::leak instead of Box::into_raw saves several bytes

asm2bf - 15 bytes
@l
psh 1
jmp %l

Will push 1 until the interpreter/system runs out of memory.

Kotlin, 27 bytes
var o=Any()
while(1>0)o={o}

Stacking functions returning functions.
54 bytes if no .kts: fun main(a:Array<String>){var o=Any();while(1>0)o={o}}

F#, 22 bytes
let rec f x=f(1::x);()
Call it in F# interactive passing an empty list: f []
The function recursively calls itself, adding elements to the list. The tuple at the end is there so that the type inference can determine that the function return type is unit.

Could this be golfed to let rec f x=1::f(x)?

@PeterTaylor your code results in StackOverflowException, which (if I  understand correctly) is not a desired outcome for this challenge. Curiously, the version I posted seems to be tail-recursive optimized.

As a side note - if StackOverflowException is a valid option, then it can be even shorter: let rec f()=1::f(). But I think it is way more fun to just watch the FSI process to eat more and more memory :)

BotEngine, 2x3=6
ve<
>e^

Rough translation:
forever:
  enqueue 'e'
  enqueue 'e'

I don’t know what this language even is, but it looks 2D — wouldn’t >e< work (or >e if there’s wrapping?)

Unfortunately, no. I believe both would produce an error (missing argument on the e instruction), and the language doesn't have wrapping.

Java 104 bytes
import java.util.*;class A{public static void main(String[]a){List b=new ArrayList();for(;;)b.add(1);}}

This will allocate a List and let it grow constantly until it runs out of space.

It might be shorter to use the fully qualified name of the class instead of importing. (see http://codegolf.stackexchange.com/a/16100/10801 and all other answers at that page. useful tips en masse there)

JavaScript - 14 18 bytes
while(x=[self.x]);

Based on the activity on @Lmis' answer, some fun with evaluating expressions in intermediate scopes. Didn't manage to avoid reference errors :'(!

Commodore 64
If ?STRING TOO LONG  ERROR counts, then this will work on the Commodore 64 and VIC-20:
0 a$=a$+" ":goto

or if you need ?OUT OF MEMORY  ERROR then:
0 dim a(255,255)

However, the last solution does not use a loop as the error is reported as soon as run is entered.

C#, 28 bytes
()=>{var _="a";for(;;)_+=_;}

What is there to say? It adds the contents of _ to _ forever. Throws OutOfMemoryException almost instantly.

c#, 55 bytes
class c{static void Main(){string c="";for(;;)c+='c';}}

Alternative 54 bytes
class c{static void Main(){string c="c";for(;;)c+=c;}}

VB.NET, 162 bytes
Module m
    Sub Main()
        Dim s = ""
        While (1)
            s = s + "1" : Threading.Thread.Sleep(2147483647)
        End While
    End Sub
End Module

It won't really run forever but close enough. It should take about 584942417 years to allocate 8gb.

Sinclair ZX80/ZX81 BASIC, ~14 bytes ~7 bytes (ZX81/ZX80 8K ROM), ~10 bytes ~5 bytes (ZX80 4K ROM)
 1 GOSUB 1

As there is never a return from the GOSUB (presented as GO SUB on the ZX80 with 4K ROM), the stack is filled which will eventually cause the interpreter to error. To clear the stack, simply enter NEW which should initiate a soft reset.

Actually one should be able to 1 GOSUB 1 - why didn't I think of that.

Whitespace, 8 bytes

Try it online!
Explanation
(s - space, t - tab, n - newline)
nssn ; Declares a label consisting of the empty sequence
nstn ; Call the procedure given by the empty label (declared above)

This is a slight abuse of the rules. The call procedure command jumps to the specified label and marks the current location for a later return. The mechanisms for doing this are implementation dependent but a basic implementation used by many interpreters is to push the current location to a call stack and pop values when a ret command is encountered. This will therefore end up filling up the call stack of the interpreter.

Whitespace, 12 bytes - Fills the stack

Try it online!
Explanation
nssn ; Declare label ''
sssn ; Push 0
nsnn ; Jump to label ''

Continuously pushes the value 0 to the stack, causing the stack to grow until the interpreter crashes.

Whitespace, 29 bytes - Fills the heap

Try it online!
Explanation
ssstn ; push 1
nssn  ; label ''
sns   ; duplicate n
tsss  ; add (effectively multiplies by 2)
sns   ; duplicate n (to use as a heap address)
sns   ; duplicate n (to use as a value)
tts   ; store n at the address n
nsnn  ; jump ''

Fills heap addresses given by 2^n with the value of 2^n, starting at n=1. Consumes memory faster on interpreters that implement the heap as an array but will also work for interpreters that use a non-contiguous data structure backing the heap (such as a dictionary/map).

Implicit, 2 bytes
(a

Try it online! (Uses up all allowed TIO memory in about 1 second)
(   create jump point
 a  push 97
    implicit infinite loop

Keg, 2 bytes
{a

Try it online!
Simply push infinite as

Flurry, 14 bytes
(<>{}{({})}){}

Adapted from this answer. One of the {} terms is replaced with {({})}, a function which pushes its argument to the stack. Thus the infinite loop grows the stack on every iteration.


text:
Please do my Martian homework
My homework is to write a Martian essay (see below) between 729 and 810 words, inclusive.  Your task is to write a program that will generate the essay.
History
Around the turn of the 20th century, spiritualist Catherine-Elise Müller allegedly communicated with Martians.  During somnambulatory trances, she would write out Martian scripts.  Psychologist Théodore Flourney discovered her Martian writings were very similar to her native French, and in his book "From India to the Planet Mars", he documented Catherine's Martian alphabet.
The following is loosely based on that alphabet with an extended mythos.
Problem Description
The Martian language has 21 letters, shown here next to each Latin equivalent:

Unfortunately, there's no Unicode for Martian (despite Mars being part of the universe), so we're stuck using Latin characters.
Whereas in English our phonemes break out into two major types (consonants/vowels) which we loosely map to letters, Martian has three letter types:

The vowels: a e i m n o u
The hard consonants: b c d g k p t
The soft consonants: f h l r s v z

In addition to this, the Martian language contains a single punctuation mark--the period.
A Martian word is a set of 3 to 9 letters.  All Martian words have at least one vowel, one hard consonant, and one soft consonant (in any arrangement).  For example, fng, cdaz, vpi, and pascal are Martian words.
A Martian sentence is a set of 3 to 9 Martian words delimited by spaces and followed by a period.
A Martian paragraph is a set of 3 to 9 Martian sentences delimited by spaces and followed by a newline.
A Martian essay is a collection of Martian paragraphs that contains no contiguous word repetitions.
A contiguous word repetition is any construct S S where S is a contiguous set of words.  Note that this definition ignores sentence and paragraph boundaries.
Examples
Please note: There's a single trailing newline following each example (since all Martian paragraphs end in a newline)
Not Martian essay
lorem ipsum dolor sit amet. quis nostrud exercitation ullamco laboris.

...for many reasons.  This example is to illustrate some miscellaneous rules:

lorem is not a Martian word because it has no hard consonants.
amet is not a Martian word because it has no soft consonants.  (m is a Martian vowel).
quis is not a Martian word because it has no hard consonants
quis is not a Martian word because q is not a Martian letter
exercitation is not a Martian word because it has more than 9 letters
exercitation is not a Martian word because x is not a Martian letter

Martian essay
fng cdaz vpi. pascal broke basic. popplers taste great.

...because it is a Martian paragraph.  The Martian paragraph contains three Martian sentences.
Not Martian essay
fng cdaz vpi. pascal broke basic. free pascal rules.

...since free pascal rules. is not a Martian sentence, because neither free nor rules are Martian words, because they do not have any hard consonants.
Martian essay
fng cdaz vpi. pascal broke basic. popplers taste great.
cdaz vpi fng. basic breaks pascal. popplers punch hard. fng cdaz vpi.

...which contains two Martian paragraphs.  The sentence fng cdaz vpi. appears twice, but that's perfectly fine.
Not Martian essay
popplers taste fng. cdaz vpi pascal. broke fng cdaz vpi.
pascal broke omicron planets. basic scares goats. vpi piv vpi.

...because the construct fng. cdaz vpi pascal. broke fng cdaz vpi. [nl] pascal broke is a contiguous word repetition.
Challenge
Your challenge is to write a function or program that accepts no input, which produces as its output my homework; that is, your program should generate a Martian essay between 729 and 810 words (inclusive).  Keep in mind, your program's output must be a valid Martian essay, but you don't have to generate it randomly or different each time.  Anything you do to generate a valid Martian essay counts.
I've written a C++ program to check essays that you're allowed to use.
This is code golf.  Shortest code in bytes wins.  Standard loopholes disallowed.

Popplers taste great... Is that futurama reference :D

The C++ checker seems to require a trailing new line.

@JonathanAllan That's correct.  Without a trailing new line, the last set of sentences cannot be a Martian paragraph (per definition of Martian paragraph).

Also, though I answered DrMcMoylex in chat, just for the record here... yes.  (FYI, the 729 and 810 word requirement, which is 1000 to 1100 words in base 9, is also an indirect reference)

@JonathanAllan I don't think the markdown supports this; added an explicit note though.

Did a bit of jiggery pokery to get one showing.

Of course!  It's part of the allowed HTML... I'll poke the rest of the examples tomorrow when I get time then.

Martians can use some vulgar language with those letters. There is a potential essay you can write using only english swear words. You could almost even call your teacher a superbitch if you could have 10 letters per word.

I think this is the first time I've seen a "Do my homework for me" question on codegolf.  Usually those are on stackoverflow proper. :-)

How does one pronounce "fng"?

When you speak of sets, you mean ordered sets, right? Is popplers taste great popplers great taste allowed? Because set of popplers taste great appears twice.

@Daerdemandt Not quite; for clarify I'll answer this backwards.  Yes, popplers taste great popplers great taste is okay.  But fng vpi fng vip fng vpi vip is okay too.  fng vpi fng vip fng vpi fng vip is not.  But "ordered set" is not the right concept here (note that {fng, vpi, fng, vip} is not an ordered set).  Think of set as simply informal for non-empty tuple.

@Cyoce. Exactly the way it's spelled.

@HWalters. Is the word you are looking for "sequence"? Also, is "... fng vpi fng. vpi ..." allowed? Notice the break by punctuation.

@MadPhysicist "Sequence" is a perfectly good term for this, but so is "tuple"; they mean the same thing.  fng vpi fng. vpi is not allowed; the break by punctuation is a "sentence boundary", and the definition given for contiguous word repetition explicitly states that sentence boundaries are ignored.  This is also illustrated in the last example (which shows a contiguous word repetition spanning both sentence and paragraph boundaries).

"basic scares goats" :/ I can confirm this is false

Husk, 19 18 bytes
↑9C9mo`:'.wC9P…"ag

Try it online!
729 words, using the same idea as the 05AB1E answer.
-1 byte from Dominic Van Essen.

Very nice, and seems to currently be the winner!  I thought (based on the spec) you could even get 17 bytes using J, but the C++ checker doesn't seem to like having a space between the last word of each sentence and the full-stop.

18 bytes using … as rangeS.

@DominicvanEssen That saves some bytes in my other answers as well..

Jelly, 28 26 25 24 23 bytes
-1 byte thanks to carusocomputing (replace the word thimble with abcdefg)
9ØaḣŒ!s²ḣµs9K€;€”.K;⁷µ€

TryItOnline!
How?
Makes a list of all 362880 permutations of the first seven nine letters of the English alphabet abcdefghi, which all have the properties of Martian words and are all distinct, and formats them into an essay using the first 729 words.
9ØaḣŒ!s²ḣµs9K€;€”.K;⁷µ€ - Main link: no arguments
9                       - 9 as x
         µ              - monadic chain separation
 Øa                     - yield lowercase alphabet
   ḣ                    - head to x ("abcdefghi")
    Œ!                  - all permutations (362880 distinct Martian words)
       ²                - square x = 81
      s                 - split into chunks of length 81 (the paragraphs)
        ḣ               - head to x (get the first 9 paragraphs only)
                     µ€ - monadic chain for €ach (for each chunk:)
          s9            -     split into chunks of length 9 (the sentences)
            K€          -     join with spaces for €each (between words in each sentence)
              ;€        -     concatenate €ach with
                ”.      -         '.' (add a full stop* after each sentence)
                  K     -     join with spaces (add a space between the sentences)
                   ;    -     concatenate with
                    ⁷   -         a line feed
                        - implicit print

* period

You can save bytes by using the first 7 characters of the alphabet abcdefg.

Gahhh... That was the byte I could've beat you with too. I'm dumb haha.

I have a feeling you'll get there anyway!

Tag, you're it, find another byte ;).

05AB1E, 25 24 22 20 bytes
-2 bytes thanks to Emigna (Significant refactor, thanks man).
A7£œJðý72ô€¨'.«9ô9£»

Try it online!
A7£                     # Push first 7 letters of the alphabet.
   œJðý                 # All 5040 permutations of "abcdefg" joined by spaces.
       72ô              # Split into pieces of 72 (Sentences).
          €             # For each piece...
           ¨'.«         # Lop of the last char and concat a period.
               9ô       # Split into pieces of 9 (paragraphs).
                 9£     # Take only the first 9 paragraphs.
                   »    # Join by newlines and implicitly print.

Turns out the 810 word version is shorter than the 729 word version.
Output:
abcdefg abcdegf abcdfeg abcdfge abcdgef abcdgfe abcedfg abcedgf abcefdg. abcefgd abcegdf abcegfd abcfdeg abcfdge abcfedg abcfegd abcfgde abcfged. abcgdef abcgdfe abcgedf abcgefd abcgfde abcgfed abdcefg abdcegf abdcfeg. abdcfge abdcgef abdcgfe abdecfg abdecgf abdefcg abdefgc abdegcf abdegfc. abdfceg abdfcge abdfecg abdfegc abdfgce abdfgec abdgcef abdgcfe abdgecf. abdgefc abdgfce abdgfec abecdfg abecdgf abecfdg abecfgd abecgdf abecgfd. abedcfg abedcgf abedfcg abedfgc abedgcf abedgfc abefcdg abefcgd abefdcg. abefdgc abefgcd abefgdc abegcdf abegcfd abegdcf abegdfc abegfcd abegfdc. abfcdeg abfcdge abfcedg abfcegd abfcgde abfcged abfdceg abfdcge abfdecg.
abfdegc abfdgce abfdgec abfecdg abfecgd abfedcg abfedgc abfegcd abfegdc. abfgcde abfgced abfgdce abfgdec abfgecd abfgedc abgcdef abgcdfe abgcedf. abgcefd abgcfde abgcfed abgdcef abgdcfe abgdecf abgdefc abgdfce abgdfec. abgecdf abgecfd abgedcf abgedfc abgefcd abgefdc abgfcde abgfced abgfdce. abgfdec abgfecd abgfedc acbdefg acbdegf acbdfeg acbdfge acbdgef acbdgfe. acbedfg acbedgf acbefdg acbefgd acbegdf acbegfd acbfdeg acbfdge acbfedg. acbfegd acbfgde acbfged acbgdef acbgdfe acbgedf acbgefd acbgfde acbgfed. acdbefg acdbegf acdbfeg acdbfge acdbgef acdbgfe acdebfg acdebgf acdefbg. acdefgb acdegbf acdegfb acdfbeg acdfbge acdfebg acdfegb acdfgbe acdfgeb.
acdgbef acdgbfe acdgebf acdgefb acdgfbe acdgfeb acebdfg acebdgf acebfdg. acebfgd acebgdf acebgfd acedbfg acedbgf acedfbg acedfgb acedgbf acedgfb. acefbdg acefbgd acefdbg acefdgb acefgbd acefgdb acegbdf acegbfd acegdbf. acegdfb acegfbd acegfdb acfbdeg acfbdge acfbedg acfbegd acfbgde acfbged. acfdbeg acfdbge acfdebg acfdegb acfdgbe acfdgeb acfebdg acfebgd acfedbg. acfedgb acfegbd acfegdb acfgbde acfgbed acfgdbe acfgdeb acfgebd acfgedb. acgbdef acgbdfe acgbedf acgbefd acgbfde acgbfed acgdbef acgdbfe acgdebf. acgdefb acgdfbe acgdfeb acgebdf acgebfd acgedbf acgedfb acgefbd acgefdb. acgfbde acgfbed acgfdbe acgfdeb acgfebd acgfedb adbcefg adbcegf adbcfeg.
adbcfge adbcgef adbcgfe adbecfg adbecgf adbefcg adbefgc adbegcf adbegfc. adbfceg adbfcge adbfecg adbfegc adbfgce adbfgec adbgcef adbgcfe adbgecf. adbgefc adbgfce adbgfec adcbefg adcbegf adcbfeg adcbfge adcbgef adcbgfe. adcebfg adcebgf adcefbg adcefgb adcegbf adcegfb adcfbeg adcfbge adcfebg. adcfegb adcfgbe adcfgeb adcgbef adcgbfe adcgebf adcgefb adcgfbe adcgfeb. adebcfg adebcgf adebfcg adebfgc adebgcf adebgfc adecbfg adecbgf adecfbg. adecfgb adecgbf adecgfb adefbcg adefbgc adefcbg adefcgb adefgbc adefgcb. adegbcf adegbfc adegcbf adegcfb adegfbc adegfcb adfbceg adfbcge adfbecg. adfbegc adfbgce adfbgec adfcbeg adfcbge adfcebg adfcegb adfcgbe adfcgeb.
adfebcg adfebgc adfecbg adfecgb adfegbc adfegcb adfgbce adfgbec adfgcbe. adfgceb adfgebc adfgecb adgbcef adgbcfe adgbecf adgbefc adgbfce adgbfec. adgcbef adgcbfe adgcebf adgcefb adgcfbe adgcfeb adgebcf adgebfc adgecbf. adgecfb adgefbc adgefcb adgfbce adgfbec adgfcbe adgfceb adgfebc adgfecb. aebcdfg aebcdgf aebcfdg aebcfgd aebcgdf aebcgfd aebdcfg aebdcgf aebdfcg. aebdfgc aebdgcf aebdgfc aebfcdg aebfcgd aebfdcg aebfdgc aebfgcd aebfgdc. aebgcdf aebgcfd aebgdcf aebgdfc aebgfcd aebgfdc aecbdfg aecbdgf aecbfdg. aecbfgd aecbgdf aecbgfd aecdbfg aecdbgf aecdfbg aecdfgb aecdgbf aecdgfb. aecfbdg aecfbgd aecfdbg aecfdgb aecfgbd aecfgdb aecgbdf aecgbfd aecgdbf.
aecgdfb aecgfbd aecgfdb aedbcfg aedbcgf aedbfcg aedbfgc aedbgcf aedbgfc. aedcbfg aedcbgf aedcfbg aedcfgb aedcgbf aedcgfb aedfbcg aedfbgc aedfcbg. aedfcgb aedfgbc aedfgcb aedgbcf aedgbfc aedgcbf aedgcfb aedgfbc aedgfcb. aefbcdg aefbcgd aefbdcg aefbdgc aefbgcd aefbgdc aefcbdg aefcbgd aefcdbg. aefcdgb aefcgbd aefcgdb aefdbcg aefdbgc aefdcbg aefdcgb aefdgbc aefdgcb. aefgbcd aefgbdc aefgcbd aefgcdb aefgdbc aefgdcb aegbcdf aegbcfd aegbdcf. aegbdfc aegbfcd aegbfdc aegcbdf aegcbfd aegcdbf aegcdfb aegcfbd aegcfdb. aegdbcf aegdbfc aegdcbf aegdcfb aegdfbc aegdfcb aegfbcd aegfbdc aegfcbd. aegfcdb aegfdbc aegfdcb afbcdeg afbcdge afbcedg afbcegd afbcgde afbcged.
afbdceg afbdcge afbdecg afbdegc afbdgce afbdgec afbecdg afbecgd afbedcg. afbedgc afbegcd afbegdc afbgcde afbgced afbgdce afbgdec afbgecd afbgedc. afcbdeg afcbdge afcbedg afcbegd afcbgde afcbged afcdbeg afcdbge afcdebg. afcdegb afcdgbe afcdgeb afcebdg afcebgd afcedbg afcedgb afcegbd afcegdb. afcgbde afcgbed afcgdbe afcgdeb afcgebd afcgedb afdbceg afdbcge afdbecg. afdbegc afdbgce afdbgec afdcbeg afdcbge afdcebg afdcegb afdcgbe afdcgeb. afdebcg afdebgc afdecbg afdecgb afdegbc afdegcb afdgbce afdgbec afdgcbe. afdgceb afdgebc afdgecb afebcdg afebcgd afebdcg afebdgc afebgcd afebgdc. afecbdg afecbgd afecdbg afecdgb afecgbd afecgdb afedbcg afedbgc afedcbg.
afedcgb afedgbc afedgcb afegbcd afegbdc afegcbd afegcdb afegdbc afegdcb. afgbcde afgbced afgbdce afgbdec afgbecd afgbedc afgcbde afgcbed afgcdbe. afgcdeb afgcebd afgcedb afgdbce afgdbec afgdcbe afgdceb afgdebc afgdecb. afgebcd afgebdc afgecbd afgecdb afgedbc afgedcb agbcdef agbcdfe agbcedf. agbcefd agbcfde agbcfed agbdcef agbdcfe agbdecf agbdefc agbdfce agbdfec. agbecdf agbecfd agbedcf agbedfc agbefcd agbefdc agbfcde agbfced agbfdce. agbfdec agbfecd agbfedc agcbdef agcbdfe agcbedf agcbefd agcbfde agcbfed. agcdbef agcdbfe agcdebf agcdefb agcdfbe agcdfeb agcebdf agcebfd agcedbf. agcedfb agcefbd agcefdb agcfbde agcfbed agcfdbe agcfdeb agcfebd agcfedb.
agdbcef agdbcfe agdbecf agdbefc agdbfce agdbfec agdcbef agdcbfe agdcebf. agdcefb agdcfbe agdcfeb agdebcf agdebfc agdecbf agdecfb agdefbc agdefcb. agdfbce agdfbec agdfcbe agdfceb agdfebc agdfecb agebcdf agebcfd agebdcf. agebdfc agebfcd agebfdc agecbdf agecbfd agecdbf agecdfb agecfbd agecfdb. agedbcf agedbfc agedcbf agedcfb agedfbc agedfcb agefbcd agefbdc agefcbd. agefcdb agefdbc agefdcb agfbcde agfbced agfbdce agfbdec agfbecd agfbedc. agfcbde agfcbed agfcdbe agfcdeb agfcebd agfcedb agfdbce agfdbec agfdcbe. agfdceb agfdebc agfdecb agfebcd agfebdc agfecbd agfecdb agfedbc agfedcb. bacdefg bacdegf bacdfeg bacdfge bacdgef bacdgfe bacedfg bacedgf bacefdg.

Looks like we both need to find one more save now :)

"." can be '. for 1 byte saved.

Or A7£œJðý72ô€¨'.«9ô9£» for 20.

Ouch. Fair dos!!

The J isn't necessary anymore (I assume the permutations builtin resulted in a list of lists before?). In addition, the ðý72ô€¨ can be golfed to 9ôðý: 16 bytes

Ruby, 86 83 82 79 bytes
(8019..8747).map{|x|$><<x.to_s(3).tr('012','abf')+(x%9>7?".\n":x%3>1?". ":" ")}

The trick: print all numbers between 102000000 and 102222222 in base 3

Where does 102M come from?

The numbers between 102000000 and 102222222 (base 3) become 9-letter words. 8019 base 10 is 102M base 3.

Python 3, 121 119 114 bytes
-5 thanks to Jitse!
from itertools import*
i=729
while i:i-=1;print(*[*permutations('thimble')][i],sep='',end='.'[i%9:]+' \n'[i%81<1])

Try it online!
How?
Counts down from i=729 and gets a list of the letters of the ith permutation of 'thimble' as the next distinct Martian word (list(permutations('thimble'))[i]).
Avoids ''.join(...) by use of a *expression to unpack the list while changing the default separator for print from a space to the empty string (sep='').
Uses the end argument of print to optionally add spaces, full stops and line feeds as required using modular arithmetic. A full stop goes after every ninth word ('.'*(i%9<1)) and a line feed goes after every eighty-first word, otherwise a space does, achieved by indexing into a two character string (' \n'[i%81<1]).

114 bytes

Thanks for that @Jitse

Mathematica, 113 bytes
StringRiffle[(p=Partition)["ark"["bus","car"][[#]]&/@Differences@Array[ThueMorse,730],3]~p~3,n=".\n",". "," "]<>n

Unnamed function that produces a string as output; that string is a Martian essay where each sentence has three words and each paragraph has three sentences. (Its deterministic output is below.)
The core of the algorithm uses the cool mathematical fact that the differences of the Thue–Morse sequence form an infinite sequence of the three symbols –1, 0, and 1 that has no contiguous digit repetitions. Differences@Array[ThueMorse,730] generates that sequence, to length 729.
Then "ark"["bus","car"][[#]]&/@ is applied to this sequence; this converts each 1 to "bus" (the first argument), each –1 to "car" (the last argument), and each 0 to "ark" (the function head). (p=Partition)[...,3]~p~3 divides this sequence of words into nested lists, each consisting of three lists of three words each. Finally, StringRiffle[...,n=".\n",". "," "] concatenates all the words together, with different separators depending on the list levels; and <>n appends the final period and newline.
The output sure doesn't look repetition-free....
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. car bus ark.
car bus car. ark bus ark. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus ark car. ark bus car.
bus ark car. bus car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus car bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
car bus ark. car bus car. ark bus ark.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. car bus ark. car bus car.
ark bus ark. car ark bus. car bus ark.
car bus car. ark bus car. bus ark car.
ark bus ark. car bus car. ark bus ark.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. car bus ark.
car bus car. ark bus ark. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car bus. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. car bus ark. car bus car.
ark bus ark. car ark bus. car bus ark.
car ark bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car bus.
car ark bus. car bus ark. car ark bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus car bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus ark car. ark bus car. bus ark car.
bus car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.
bus car bus. ark car bus. car ark bus.
car bus ark. car ark bus. ark car bus.
car ark bus. ark car ark. bus car bus.
ark car ark. bus ark car. bus car ark.
bus car bus. ark car bus. car ark bus.
ark car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus ark car.
ark bus car. bus ark car. bus car ark.
bus car bus. ark car ark. bus ark car.
bus car ark. bus ark car. ark bus car.
bus ark car. ark bus ark. car bus car.
ark bus car. bus ark car. bus car ark.
bus ark car. ark bus car. bus ark car.
bus car ark. bus car bus. ark car ark.
bus ark car. bus car ark. bus car bus.
ark car bus. car ark bus. ark car ark.

Mathematica, 100 bytes
StringRiffle[(p=Partition)[Permutations@Characters@"thimble"~Take~729,9]~p~9,n=".\n",". "," ",""]<>n

A direct port of Jonathan Allen's Jelly algorithm.

I see car bus car bus in there

Wait nvm just my display

It would be shorter to just do Print@"fng cdaz vpi. pascal broke basic. popplers taste great."

@Pavel Perfectly valid essay, but you're about 720 words shy of my homework assignment.

@HWalters I see, I misread the problem. Oops.

JavaScript (ES6), 130 bytes
This essay contains 774 Martian words, from a dictionary of 308 distinct words, made of all Martian letters.
_=>[...Array(2322)].map((_,i)=>['aeimnou','bcdgkpt','fhlrsvz'][i%3][(z=z*71%1e9)%7]+(++i%3?'':i%9?' ':i%27?'. ':`.
`),z=1).join``

Letters are picked in a pseudo-random manner, using the following formula:
(71^n mod 1000000000) mod 7

Where 71 is the smallest prime [1] for which no contiguous word repetition appear with this modulo.

let f =

_=>[...Array(2322)].map((_,i)=>['aeimnou','bcdgkpt','fhlrsvz'][i%3][(z=z*71%1e9)%7]+(++i%3?'':i%9?' ':i%27?'. ':`.
`),z=1).join``

console.log(f());

[1] I only tested primes at the time I wrote this code. The smallest non-prime candidate is 56.

PHP, 86 bytes
for(;$i<729;$$s="")echo${$s=str_shuffle(abcdefg)}??$s.(++$i%3?"":".").($i%9?" ":"\n");

Generates a randomised 729 word essay that repeats no words.
Use like:
php -r 'for(;$i<729;$$s="")echo${$s=str_shuffle(abcdefg)}??$s.(++$i%3?"":".").($i%9?" ":"\n");'

Explanation:
for(;$i<729;                                      # until we've generated 729 words
  $$s="")                                         # assign a blank string to the variable for the previous word
    echo ${$s=str_shuffle(abcdefg)}??             # generate a random word and if the variable for it has been assigned echo that variable (a blank string)
         $s.(++$i%3?"":".").($i%9?" ":"\n");      # otherwise echo the string and punctuation based on the word number (which is incremented here)

newline counts as one byte, so it´s 85 not 86. Amazing golf!

for($i=729;;$$ss="")...(--$i%3...)... should work as well and avoid a notice/warning.

///, 95 bytes
/_/abf//-/_ _a _e _i _m _n _o _u _aa.//'/- b- c- d- g- j- p- t- bb-/'
f'
h'
l'
r'
s'
v'
z'
ff'

(additional new line at the end, not visible here)
Try it online!
Essay:
abf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
fabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
habf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
labf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
rabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
sabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
vabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
zabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.
ffabf abfa abfe abfi abfm abfn abfo abfu abfaa. babf abfa abfe abfi abfm abfn abfo abfu abfaa. cabf abfa abfe abfi abfm abfn abfo abfu abfaa. dabf abfa abfe abfi abfm abfn abfo abfu abfaa. gabf abfa abfe abfi abfm abfn abfo abfu abfaa. jabf abfa abfe abfi abfm abfn abfo abfu abfaa. pabf abfa abfe abfi abfm abfn abfo abfu abfaa. tabf abfa abfe abfi abfm abfn abfo abfu abfaa. bbabf abfa abfe abfi abfm abfn abfo abfu abfaa.

Python 3, 404 270 332 339 285 266 259 bytes
This is an attempt to create a random Martian essay my randomly sampling the Martian alphabet and checking afterwards which words work.
Edit: -10 bytes from Zachary T's suggestion to use R=range. -9 bytes from changing .intersection(w) to &set(w). -7 bytes from changing A[random.randrange(21)] to random.choice(A).
import random
W=[];A="abfechidlmgrnksopvutz";R=range
while len(W)<729:W+=[''.join(random.choice(A)for j in R(9))for i in R(729)];W=[*set(w for w in W if all(set(A[z::3])&set(w)for z in R(3)))]
for j in R(9):print(" ".join(W[81*j+i]+"."*(i%9>7)for i in R(81)))

Ungolfing
import random
word_list = []
alphabet = "abfechidlmgrnksopvutz"
while len(word_list) < 729:
    # generates words
    for i in range(729):
        word = ""
        for j in range(9):
            word += alphabet[random.randrange(21)]
        word_list.append(word)
    # removes invalid words that don't have at least one letter of each letter type
    kept_words = []
    for word in word_list:
        all_letter_types = [0, 0, 0]
        for z in range(3):
            all_letter_types[z] = set(alphabet[z::3]) & set(word)
        if all(all_letter_types):
            kept_words.append(word)
    word_list = kept_words[:]
    # removes any contiguous word repetitions by removing all repeated words
    word_list = list(set(word_list))
# attaches punctuation and prints
for j in range(9):
    result = []
    for i in range(81):
        word = word_list[81*j+i]
        if i%9 == 8:
            word += "."
    print(" ".join(result))

You don't need the overhead of a function since there is no input it could just be the content of a file (i.e. a module). You don't need to make it random (although if you do want to use the module you'll need an import)

@JonathanAllan I knew I forgot something. Thanks for the heads up. I wanted to try a random answer anyway. EDIT: Oddly enough, adding the import and removing the indentation levels of the function overhead cancel each other out. Strange.

Can you save bytes by assigning range(9) to a variable, as well as & instead of .intersection?

Or by assigning a variable to range, then using that?

Zsh -P, 51 bytes
x=(a e i m n o u)
echo $x{f,h,l,r,s}$x{b,d,g.}|fold

Attempt This Online!
The output has some trailing spaces, which I think are normally allowed, but if not, this can be fixed by adding |cut -c-79 (+10 bytes).
Explanation
The basic idea is to generate a number of unique Martian words, then group them into sentences and paragraphs.
I used 4-letter words of the format vsvh (vowel, soft consonant, vowel, hard consonant), because it makes it possible to get enough words using just one cartesian product. (This is what the {,,,} expansions do; the -P option to Zsh also enables that multiplying behaviour for array variables, allowing us to reuse $x).
There are enough unique 3-letter words to meet the word count, but they would require multiple separate expansions - one single format (e.g. vsh) can only produce \$ 7^3 = 343 \$ words. This would take too many extra bytes.
Then, by adding a . to one of the letters, we can ensure there are regular sentence breaks - here, it's every time g comes around in the cartesian product.
Finally, piping this all to fold inserts line breaks, to keep the paragraphs under 10 sentences each.
The fact that this all works, and can be so short, is slightly miraculous. It relies on some very specific mathematical properties: by having \$ x = 7 \$ vowels, \$ y = 5 \$ soft consonants, and \$ z = 3 \$ hard consonants, we ensure:

\$ 729 \le xyxz \le 810 \$, so our essay meets the word count
\$ z \ge 3 \$, so each sentence has enough words in it (remember one of the hard consonants has a . at the end)
\$ 80 \div (5z+1) \in \mathbb Z \cap [3, 9] \$, so the fold command, which defaults to wrapping every 80 characters, will break the essay up into paragraphs with a valid integer number of sentences
\$ xyxz \equiv 0 \mod (80 \div (5z+1))z \$, so the last paragraph doesn't have any remainder sentences

Any of the issues above could be worked around, of course, but that would cost extra bytes. \$ 7, 5, 3 \$ is actually the only choice that works perfectly!

K (ngn/k), 167 148 145 144 bytes
{("\n"/(" "/'(" "/''$(729>#,//){x,,(3+*1?7){l:3+*1?7;x,,`$(-#:'w)?'w:(,/'+l?'0 7 14_c),'(l?7)?\:c:"aeimnoubcdgkptfhlrsvz"}/()}/()),''".")),"\n"}

Try it online!
Stitches together a random character of each type, appending an additional 0-6 random characters to form words of length 3-9, which are then shuffled. Sentences are formed from 3-9 of these words, and paragraphs from 3-9 of those sentences.
Paragraphs are iteratively appended, with the essay being complete when it contains at least 729 words. Since a valid paragraph can only contain up to 81 words (9 words per sentence * 9 sentences), it's safe to write another paragraph as long as the essay contains less than 729 words.
However, proofreading the essay to ensure there is no contiguous word repetition is an exercise left to the reader.
{("\n"/                                /join each paragraph with a newline
  (" "/'                               /join sentences in a paragraph with a space
   (" "/''$                            /join words in a sentence with a space (converting words from symbols to strings)
    (729>#,//){                        /while the essay contains less than 729 words...
     x,,                                /append another paragraph of...
     (3+*1?7){                          /3 to 9 (randomly chosen) sentences each containing...
      l:3+*1?7;                         /3 to 9 (randomly chosen) words
      x,,`$                             /append the new sentence (casted to symbols), which is made of l words, each being a...
      (-#:'w)?'                         /randomly shuffled string of...
      w:(,/'+l?'0 7 14_c)               /a random character from each character type in the Martian alphabet
      ,'                                /concatenated with...
      (l?7)?\:c:"aeimnoubcdgkptfhlrsvz" /0 to 6 random characters from the Martian alphabet
     }/()
    }/()
   )
   ,''"."                               /finish each sentence with a period
  )
 )
 ,"\n"                                  /finish the essay with a newline
}

-1: {729>#,//x} -> (729>#,//)

CJam, 26 bytes
'h,97>e!".
"{9/Sf*Uf+}fU9<

Try it online!
First solution in a while where I've had to use a literal newline. Same idea as the 05AB1E answer.
sigh And if only concatenation was commutative...

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Railroad switch network
Introduction
Suppose we have a network of railroads.
Each junction in the network is controlled by a switch, which determines whether an incoming train turns left or right.
The switches are configured so that each time a train passes, the switch changes direction: if it was pointing left, it now points right, and vice versa.
Given the structure of the network and the initial positions of the switches, your task is to determine whether a train can eventually pass through it.
This challenge was inspired by this article.
Input
Your input is a non-empty list S of pairs S[i] = (L, R), where each of L and R is an index of S (either 0-based or 1-based), in any reasonable format.
This includes a 2 × N matrix, an N × 2 matrix, two lists of length N, or a list of length 2N.
Each pair represents a junction of the network, and L and R point to the junctions that are reached by turning left and right from the junction.
They may be equal and/or point back to the junction i.
All junctions initially point left.
Output
A train is placed on the first junction S[0].
On each "tick", it travels to the junction that its current switch points to, and that switch is then flipped to point to the other direction.
Your output shall be a truthy value if the train eventually reaches the last junction S[length(S)-1], and a falsy value if is doesn't.
Example
Consider this network:

This corresponds to the input [(1,2),(0,3),(2,0),(2,0)]
The train travels the following route:
[0] -L-> [1] -L-> [0] -R-> [2] -L-> [2] -R-> [0] -L-> [1] -R-> [3]

Since the train reached its destination, the last junction, the correct output is truthy.
For the input [(1,2),(0,3),(2,2),(2,0)] we have the following route:
[0] -L-> [1] -L-> [0] -R-> [2] -L-> [2] -R-> [2] -L-> [2] -R-> ...

This time, the train got stuck in the junction 2, and will never reach the destination.
The correct output is thus falsy.
Rules and scoring
You can write a full program or a function, and the lowest byte count wins.
Consider skimming the article, as it may contain useful info for writing a solution.
Test cases
These have 0-based indexing.
[(0,0)] -> True
[(0,1),(0,0)] -> True
[(0,0),(1,0)] -> False
[(1,2),(0,3),(2,0),(1,2)] -> True
[(1,2),(0,3),(2,2),(1,2)] -> False
[(1,2),(3,0),(2,2),(1,2)] -> True
[(1,2),(2,0),(0,2),(1,2)] -> False
[(0,2),(4,3),(0,4),(1,2),(4,1)] -> True
[(4,0),(3,0),(4,0),(2,0),(0,4)] -> True
[(1,4),(3,2),(1,4),(5,3),(1,0),(5,2)] -> True
[(3,1),(3,2),(1,5),(5,4),(1,5),(3,2)] -> True
[(1,2),(5,0),(3,2),(2,4),(2,3),(1,6),(1,2)] -> False
[(4,9),(7,3),(5,2),(6,4),(6,5),(5,4),(3,2),(6,8),(8,9),(9,1)] -> False
[(2,7),(1,5),(0,8),(9,7),(5,2),(0,4),(7,6),(8,3),(7,0),(4,2)] -> True
[(4,9),(7,3),(3,2),(8,3),(1,2),(1,1),(7,7),(1,1),(7,3),(1,9)] -> False
[(0,13),(3,6),(9,11),(6,12),(14,11),(11,13),(3,8),(8,9),(12,1),(5,7),(2,12),(9,0),(2,1),(5,2),(6,4)] -> False
[(6,0),(1,2),(14,1),(13,14),(8,7),(6,4),(6,10),(9,10),(10,5),(10,9),(8,12),(14,9),(4,6),(11,10),(2,6)] -> False
[(1,3),(9,17),(5,1),(13,6),(2,11),(17,16),(6,12),(0,8),(13,8),(10,2),(0,3),(12,0),(3,5),(4,19),(0,15),(9,2),(9,14),(13,3),(16,11),(16,19)] -> True

Do I understand it correctly that this basically Langton's Ant on an arbitrary graph? (I guess except for the fact that "left" and "right" are global directions and don't depend on the incoming direction of the train.)

@MartinEnder Yes, this is very similar to Langton's ant, although I think the ant can't be represented in this exact model.

Tangentially related

@Sp3000 My thoughts exactly, before even tapping on the title in the network feed!

CJam, 30 29 bytes
0l~_,m!{_2$=(@@2$+3$\t}*,(])&

Uses 0-based inputs and prints the index of the terminal node if the terminal node is ever reached.
This is super inefficient. You wouldn't want to test this on inputs with more than 10 nodes. The test link below uses 2\# instead of m! which isn't quite enough for all possible inputs, but it passes all test cases in a few seconds (and one would have try fairly hard to find a test case that doesn't pass).
Try it online!
Explanation
This doesn't have any loop or terminal detection. Instead we simply iterate the system often enough that we know we've hit a loop, recording the history, and then we check whether we've reached the terminal node at any point.
If we don't visit the terminal node, we only modify the states of N-1 nodes (if N is the total number of nodes). Each of the nodes has two different states, and the train can be on any one of those nodes (thanks to ais523 for pointing this out), so there are 2(N-1)*(N-1) different states we can visit before entering a loop or reaching the terminal node. Since we start from one of these states we know that after 2(N-1)*(N-1) transitions, we've either entered a loop or reached the terminal node.
That's a fairly lengthy expression. However, N! is almost never less than 2(N-1)*(N-1). In fact, the only N for which that's the case is 3, where the number of possible states is 8 and N! gives only 6. That said, it's not necessarily the case that it's possible to reach all theoretical states in any of the possible inputs. It's fairly easy to check this exhaustively: the neighbours of the last node are always irrelevant, so we can simply consider all inputs of the form [[a b] [c d] [0 0]] where at least one of abcd contains 2 (otherwise, the terminal state is guaranteed to be unreachable). There are only 65 of these states, and I ran them through a slightly modified program, which finds the first transition after which the terminal state is reached (or -1 if it's unreachable). As it turns out, it's impossible to construct an input which requires more than 6 transitions to reach the terminal state, just what we need. Hence, I'm using N! as the upper bound of iterations.
0      e# Push a zero. This is the initial node index of the train.
l~     e# Read and evaluate the input.
_,m!   e# Compute the factorial of N.
{      e# Run this block N! times.
  _    e#   Copy the list of LR pairs.
  2$=  e#   Copy the current node index and extract the corresponding pair.
  (    e#   Pull off the first neighbour - this is where the train moves next.
  @@   e#   Pull list of pairs and the list with the other neighbour on top.
  2$+  e#   Copy the first neighbour and append it. This effectively, reverses
       e#   the pair so that next time the other destination from the current
       e#   node is picked.
  3$   e#   Copy the current node again.
  \    e#   Swap it with the reversed pair.
  t    e#   Write the reversed pair back into the full list of pairs.
       e#   In summary, one iteration extracts the first neighbour of the
       e#   current node and leaves it on the stack, and swaps the neighbours
       e#   of that node for future visits.
}*     e# At the end, we've got all the reachable nodes on the stack, and
       e# the list of all pairs still on top.
,(     e# Compute N-1 from the list of pairs.
])     e# Wrap everything in a list and remove N-1 from it.
&      e# Compute the set intersection all reachable nodes with N-1.

2N-1 is not enough; you need to multiply by N as well, because that's part of the state too. (N factorial should still be enough, though, except on very small problems, and it may well be that you can't construct a problem to use the maximum number of transitions.)

@ais523 Oh that's a good point. N! is guaranteed to be large enough for all N except 3. I'll go with (N+1)! until I've verified that N! is enough for N == 3.

@ais523 Updated with a link that shows that N! factorial is enough for N == 3 as well.

@ais523 I've brute forced all possible inputs up to N = 6 and the maximum number of iterations is always 2^N-2. No clue how to prove that though.

Perl, 52 + 2 = 54 bytes
$F[$1/($@++<@F<<@F)]=~s/(.+),(.+)/$2,$1/ while$1<$#F

Run with -ap (2 byte penalty). Input is a single line in the format 1,2 0,3 2,2 2,0.
Prints a copy of the input (which is truthy in Perl, as it's a string more than one byte long) to standard output on success, or crashes via dividing by zero (producing nothing on standard output; the null string is falsey) on failure.
The algorithm is very simple; we simply simulate the movement of the train, remembering its current location in $1 (whose initial value is zero when seen as an integer, and which automatically updates to hold the first capture group every time a regex is run), and the current states of the track by overriding @F (which holds the input array, and is input via the -a option on the command line). In order to detect that we've got stuck in a loop, we use $@ to count the number of steps taken; if this exceeds the number of switches times 2 to the power of the number of switches (a formula that can be conveniently written in Perl as @F<<@F and which is only slightly higher than the actual upper bound), we're necessarily stuck in a loop, because seeing the same (track, train) state twice will cause an infinite loop in this problem, and we've already been through more states than there are distinct states (so by the pigeonhole principle, we must have seen at least one twice).

Haskell, 114 95 88 84 bytes
(o%h)g|elem(o,g)h=1<0|(a,(l,r):b)<-splitAt o g=null b||(l%((o,g):h)$a++(r,l):b)
0%[]

Keeps a history of visited (location, network) pairs to be able to decide a failure. Junctions tuples are swapped when visited.
Usage:
0%[]<$>[[(0,0)] ,[(0,1),(0,0)] ,[(0,0),(1,0)] ,[(1,2),(0,3),(2,0),(1,2)] ,[(1,2),(0,3),(2,2),(1,2)] ,[(1,2),(3,0),(2,2),(1,2)] ,[(1,2),(2,0),(0,2),(1,2)] ,[(0,2),(4,3),(0,4),(1,2),(4,1)] ,[(4,0),(3,0),(4,0),  (2,0),(0,4)] ,[(1,4),(3,2),(1,4),(5,3),(1,0),(5,2)] ,[(3,1),(3,2),(1,5),(5,4),(1,5),(3,2)] ,[(1,2),(5,0),(3,2),(2,4),(2,3),(1,6),(1,2)] ,[(4,9),(7,3),(5,2),(6,4),(6,5),(5,4),(3,2),(6,8),(8,9),(9,1)] ,[(2,7),(1,  5),(0,8),(9,7),(5,2),(0,4),(7,6),(8,3),(7,0),(4,2)] ,[(4,9),(7,3),(3,2),(8,3),(1,2),(1,1),(7,7),(1,1),(7,3),(1,9)] ,[(0,13),(3,6),(9,11),(6,12),(14,11),(11,13),(3,8),(8,9),(12,1),(5,7),(2,12),(9,0),(2,1),(5,2),  (6,4)] ,[(6,0),(1,2),(14,1),(13,14),(8,7),(6,4),(6,10),(9,10),(10,5),(10,9),(8,12),(14,9),(4,6),(11,10),(2,6)] ,[(1,3),(9,17),(5,1),(13,6),(2,11),(17,16),(6,12),(0,8),(13,8),(10,2),(0,3),(12,0),(3,5),(4,19),(0,  15),(9,2),(9,14),(13,3),(16,11),(16,19)]]
[True,True,False,True,False,True,False,True,True,True,True,False,False,True,False,False,False,True]

Ungolfed:
rails location history network
  | elem state history = False                         --We are stuck in a loop
  | otherwise = null b || (rails l newHistory swapped) --b is empty when location is last element in list
  where
  (a, (left, right):b) = splitAt location network
  swapped            = a ++ (right, left):b
  state              = (location, network)
  newHistory         = state:history

Thanks @Zgarb for saving 4 bytes

I think you have some superfluous parentheses there (both calls of %).

@Zgarb good catch

Python 135 133 bytes
-1 byte thanks to Angs (l>len(c)-2 rather than l==len(c)-1)
def f(c,p=0,l=0,h=[]):j=len(c);p=p or[0]*j;s=p[:],l;r=2*(l>j-2)or(s in h);n=c[l][p[l]];p[l]=1-p[l];return r-1if r else f(c,p,n,h+[s])

repl.it
Returns 1 (truthy) if the goal is reached; or 0 (falsey) if a state is reached that has been reached before. Otherwise recurses updating the state.
c is the network. p is the current state of each switch (initialised to all left as [0]*len(c) on the first run). l is the current location. h is the state history, to which s, a tuple of a copy of p and l, is added.

l>len(c)-2 saves a byte

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/