1

Because in pure functional programming objects are all immutable, is it still possible to create memory leak?

By pure functional program, I meant there are no side effect. Of course, this is not realistic since every program has I/O. But, let's just ignore the I/O for now.

9
  • You can cause Stack Overflow with recursive functions. very easy. Commented Jun 20, 2017 at 4:06
  • You can also hold onto the head of a sequence. Commented Jun 20, 2017 at 4:13
  • You might find this interesting: stackoverflow.com/questions/9952602/… Commented Jun 20, 2017 at 4:14
  • 1
    How do you define memory leak in this context? Also, there is no pure functional program, otherwise you would never see a result of your program. Commented Jun 20, 2017 at 4:15
  • I think by the definition, stack overflow is not memory leak since you don't loose any references. Commented Jun 20, 2017 at 4:15

1 Answer 1

2

I think this is a matter of how we define a memory leak. A program that runs for a very long time (potentially endlessly, like a server) can have a memory usage that is bounded or that grows more and more the longer the program is running. In the latter case, one speaks usually of a memory leak.

It is easy to write a functional program that needs more and more memory the longer it runs. So in that sense, memory leaks are possible.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.