From 6887d02be0e31c24008a438b234b7e56f9422f9a Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Fri, 17 May 2024 22:59:47 +0100 Subject: [PATCH] Alter wording --- README.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f289b80..18c0cff 100644 --- a/README.md +++ b/README.md @@ -57,14 +57,11 @@ pub fn main() { gleam add gleam_pgo ``` -## Limitations +## Atom generation -Currently, this package should be used to instanciate a bunch of connections, -and reuse them everywhere. __Do not__ open and close connections dynamically, -for instance at launch and shutdown of a process. This will expose your -application to a memory leak, and will lead to undesired runtime crashes. - -> Why is that happening? To maintain the PG connection, PGO needs to keep an Erlang atom. -> Erlang atom are specials, because they're allowed once when using them, and -> they're never garbaged. When generating dynamically lots of atoms, you expose -> your application to a memory leak. +Creating a connection pool with the `pgo.connect` function dynamically generates +an Erlang atom. Atoms are not garbage collected and only a certain number of +them can exist in an Erlang VM instance, and hitting this limit will result in +the VM crashing. Due to this limitation you should not dynamically open new +connection pools, instead create the pools you need when your application starts +and reuse them throughout the lifetime of your program.