You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is problematic when deploying an agent on an environment that has limited resources, and a character file with a lot of memories to create. Having a lot of knowledge in your character file will instantly get your memory footprint above 10gb and it will stay that high until the process is killed.
Here is the results of inserting a log in every iteration processCharacterKnowledge and inserting 120ish random sentences into the "knowledge" of c3po example character file
run 0: 829.88 MB (0.81 GB)
run 1: 1050.15 MB (1.03 GB)
run 2: 1294.02 MB (1.26 GB)
run 3: 1527.19 MB (1.49 GB)
run 4: 1771.96 MB (1.73 GB)
run 5: 2981.71 MB (2.91 GB)
run 6: 3225.91 MB (3.15 GB)
run 7: 3467.36 MB (3.39 GB)
run 8: 3706.70 MB (3.62 GB)
run 9: 4184.69 MB (4.09 GB)
run 10: 4669.60 MB (4.56 GB)
run 11: 5147.63 MB (5.03 GB)
run 12: 5382.70 MB (5.26 GB)
run 13: 5608.27 MB (5.48 GB)
run 14: 6085.95 MB (5.94 GB)
run 15: 6547.88 MB (6.39 GB)
run 16: 7012.85 MB (6.85 GB)
run 17: 7488.52 MB (7.31 GB)
run 18: 7728.45 MB (7.55 GB)
run 19: 8200.47 MB (8.01 GB)
run 20: 8674.36 MB (8.47 GB)
run 21: 9125.14 MB (8.91 GB)
run 22: 9589.82 MB (9.37 GB)
run 23: 9708.89 MB (9.48 GB)
run 24: 5511.07 MB (5.38 GB)
run 25: 5238.44 MB (5.12 GB)
run 26: 5255.96 MB (5.13 GB)
run 27: 5292.35 MB (5.17 GB)
run 28: 5343.29 MB (5.22 GB)
run 29: 5363.51 MB (5.24 GB)
run 30: 5430.72 MB (5.30 GB)
run 31: 5484.32 MB (5.36 GB)
run 32: 5620.34 MB (5.49 GB)
run 33: 5707.05 MB (5.57 GB)
run 34: 5870.03 MB (5.73 GB)
run 35: 6069.80 MB (5.93 GB)
run 36: 6261.48 MB (6.11 GB)
run 37: 6501.14 MB (6.35 GB)
run 38: 6991.68 MB (6.83 GB)
run 39: 7236.04 MB (7.07 GB)
run 40: 7627.52 MB (7.45 GB)
run 41: 8037.95 MB (7.85 GB)
run 42: 8277.20 MB (8.08 GB)
run 43: 8517.22 MB (8.32 GB)
run 44: 8968.85 MB (8.76 GB)
run 45: 9430.57 MB (9.21 GB)
run 46: 7204.91 MB (7.04 GB)
run 47: 7206.63 MB (7.04 GB)
run 48: 7210.38 MB (7.04 GB)
run 49: 7232.14 MB (7.06 GB)
run 50: 7277.31 MB (7.11 GB)
run 51: 7357.45 MB (7.19 GB)
run 52: 7403.78 MB (7.23 GB)
run 53: 7465.70 MB (7.29 GB)
run 54: 7528.90 MB (7.35 GB)
run 55: 7560.23 MB (7.38 GB)
run 56: 7597.09 MB (7.42 GB)
run 57: 7650.72 MB (7.47 GB)
run 58: 7712.67 MB (7.53 GB)
run 59: 7764.50 MB (7.58 GB)
run 60: 7783.21 MB (7.60 GB)
run 61: 8165.85 MB (7.97 GB)
run 62: 8643.23 MB (8.44 GB)
run 63: 8882.75 MB (8.67 GB)
run 64: 9124.89 MB (8.91 GB)
run 65: 9597.12 MB (9.37 GB)
run 66: 8282.90 MB (8.09 GB)
run 67: 8283.68 MB (8.09 GB)
run 68: 8286.03 MB (8.09 GB)
run 69: 8289.93 MB (8.10 GB)
run 70: 8310.79 MB (8.12 GB)
run 71: 8336.25 MB (8.14 GB)
run 72: 8355.52 MB (8.16 GB)
run 73: 8372.96 MB (8.18 GB)
run 74: 8404.90 MB (8.21 GB)
run 75: 8440.03 MB (8.24 GB)
run 76: 8511.20 MB (8.31 GB)
run 77: 8548.01 MB (8.35 GB)
run 78: 8622.02 MB (8.42 GB)
run 79: 8674.16 MB (8.47 GB)
run 80: 8735.84 MB (8.53 GB)
run 81: 8799.57 MB (8.59 GB)
run 82: 8834.56 MB (8.63 GB)
run 83: 9239.15 MB (9.02 GB)
run 84: 8585.31 MB (8.38 GB)
run 85: 8586.25 MB (8.39 GB)
run 86: 8587.19 MB (8.39 GB)
run 87: 8587.66 MB (8.39 GB)
run 88: 8588.75 MB (8.39 GB)
run 89: 8589.84 MB (8.39 GB)
run 90: 8594.53 MB (8.39 GB)
run 91: 8614.29 MB (8.41 GB)
run 92: 8649.79 MB (8.45 GB)
run 93: 8665.30 MB (8.46 GB)
run 94: 8690.28 MB (8.49 GB)
run 95: 8705.19 MB (8.50 GB)
run 96: 8725.31 MB (8.52 GB)
run 97: 8783.15 MB (8.58 GB)
run 98: 8820.63 MB (8.61 GB)
run 99: 8836.03 MB (8.63 GB)
run 100: 8873.71 MB (8.67 GB)
run 101: 8958.09 MB (8.75 GB)
run 102: 8995.14 MB (8.78 GB)
run 103: 9049.34 MB (8.84 GB)
run 104: 9086.52 MB (8.87 GB)
run 105: 9129.66 MB (8.92 GB)
run 106: 9238.74 MB (9.02 GB)
run 107: 9656.99 MB (9.43 GB)
run 108: 10127.65 MB (9.89 GB)
run 109: 10350.61 MB (10.11 GB)
run 110: 10587.35 MB (10.34 GB)
run 111: 9375.50 MB (9.16 GB)
run 112: 9377.06 MB (9.16 GB)
run 113: 9383.47 MB (9.16 GB)
run 114: 9385.50 MB (9.17 GB)
run 115: 9386.28 MB (9.17 GB)
run 116: 9388.47 MB (9.17 GB)
run 117: 9388.94 MB (9.17 GB)
run 118: 9391.44 MB (9.17 GB)
run 119: 9392.69 MB (9.17 GB)
run 120: 9393.47 MB (9.17 GB)
run 121: 9430.66 MB (9.21 GB)
run 122: 9445.50 MB (9.22 GB)
run 123: 9482.61 MB (9.26 GB)
run 124: 9552.21 MB (9.33 GB)
run 125: 9591.24 MB (9.37 GB)
run 126: 9628.11 MB (9.40 GB)
run 127: 9671.48 MB (9.44 GB)
run 128: 9737.57 MB (9.51 GB)
After this the memory footprint stayed at around 9.5.gb +- 200mb until i killed the process, and when restarted ran comfortable <2gb memory because the database already had the memories so this was skipped.
As you can see in run 23 and 45 there is a some sort of garbage collection but im not sure what triggers this. But I have even tried exposing v8 gc and forcing collection after memories are inserted, but it didnt help much.
The problem most definitely lies in fastembed but its not obvious. Just thought I would bring this to your attention maybe someone has some ideas
To Reproduce
You can just fill any of the example agents with a lot of knowledge and start it and check your resources. Here is one of random sentences i would add to c3po's knowledge to test
"knowledge": [
"The old bicycle squeaked as she pedaled down the cobblestone street.",
"A rainbow appeared briefly after the summer storm.",
"The chef carefully plated the delicate dessert with artistic precision.",
"Ancient manuscripts revealed secrets of forgotten civilizations.",
"The cat chased a butterfly through the garden of wildflowers.",
"Stars twinkled mysteriously in the clear night sky.",
"Steam rose gently from the cup of freshly brewed coffee.",
"Children's laughter echoed through the playground at recess.",
"The artist mixed colors on her palette with deliberate strokes.",
"Waves crashed against the rocky shoreline at sunset.",
"A gentle breeze rustled through the autumn leaves.",
"The grandfather clock chimed twelve times at midnight.",
"Fresh bread scented the entire bakery with warmth.",
"Scientists discovered a new species in the Amazon rainforest.",
"The violin's melody floated through the concert hall.",
"Snow fell silently on the sleeping town.",
"Ancient trees whispered stories to those who listened closely.",
"The telescope revealed distant galaxies never seen before.",
"A fox darted quickly across the moonlit field.",
"The old bookshop held countless untold adventures.",
"Wind chimes created a peaceful melody in the garden.",
"The museum's artifacts spoke of forgotten times.",
"Fireflies danced in the summer evening air.",
"The chef's knife moved with practiced precision.",
"Morning dew sparkled on spider webs like diamonds.",
"The train whistle echoed through the valley.",
"Sailors watched the approaching storm with concern.",
"The typewriter's keys clicked rhythmically in the quiet room.",
"Mountain peaks disappeared into the misty clouds.",
"The librarian carefully restored the ancient manuscript.",
"Sunflowers turned their faces toward the morning light.",
"The blacksmith's hammer rang out across the village.",
"Children built sandcastles on the sunny beach.",
"The photographer captured the perfect moment at sunset.",
"Moths danced around the porch light at dusk.",
"The aroma of fresh coffee filled the morning air.",
"Leaves crunched beneath her boots on the forest path.",
"The old piano played a melancholy tune.",
"Fish darted through the crystal-clear stream.",
"The astronomer tracked a mysterious celestial object.",
"Rain drummed steadily on the tin roof.",
"The gardener tenderly pruned the rose bushes.",
"Bees buzzed busily among the lavender plants.",
"The potter's wheel spun rhythmically and steadily.",
"A shooting star streaked across the night sky.",
"The old map revealed hidden treasure locations.",
"Waves gently lapped at the sandy shore.",
"The painter captured the sunrise in vibrant colors.",
"Birds sang their morning chorus at dawn.",
"The metalsmith crafted intricate jewelry pieces.",
"Autumn leaves swirled in the afternoon breeze.",
"The scientist recorded her latest observations.",
"Candlelight flickered on the dining room walls.",
"The storyteller captivated her young audience.",
"Snow covered the mountain peaks year-round.",
"The archaeologist carefully excavated ancient ruins.",
"Butterflies fluttered through the flower garden.",
"The chef's kitchen bustled with activity.",
"Moonlight silvered the peaceful lake surface.",
"The clockmaker repaired delicate mechanisms.",
"Children flew kites in the spring breeze.",
"The violinist tuned her instrument carefully.",
"Fog rolled in from the distant harbor.",
"The glassblower created delicate sculptures.",
"Rain clouds gathered on the horizon.",
"The weaver worked intricate patterns into fabric.",
"Deer grazed quietly in the morning meadow.",
"The lighthouse beam cut through the darkness.",
"Steam engines powered the old factory.",
"The botanist classified new plant species.",
"Snowflakes fell silently in the forest.",
"The sailor navigated by the stars alone.",
"Wind rustled through tall prairie grass.",
"The carpenter crafted fine wooden furniture.",
"Owls hunted silently in the night.",
"The composer wrote a new symphony.",
"Waterfalls cascaded down rocky cliffs.",
"The baker kneaded dough with strong hands.",
"Crickets chirped in the summer evening.",
"The astronaut gazed at Earth from space.",
"Desert winds shaped the ancient dunes.",
"The watchmaker assembled tiny gears.",
"Dolphins played in the ship's wake.",
"The explorer mapped unknown territories.",
"Frost patterns decorated window panes.",
"The sculptor shaped clay with precision.",
"Hawks soared on thermal currents.",
"The perfumer blended exotic scents.",
"River waters flowed endlessly downstream.",
"The painter mixed colors on her palette.",
"Wolves howled at the full moon.",
"The architect designed innovative structures.",
"Cherry blossoms fell like pink snow.",
"The beekeeper tended his busy hives.",
"Mountains reflected in still lake waters.",
"The writer crafted stories late at night.",
"Autumn colors painted the hillsides.",
"The jeweler set precious stones carefully.",
"Seabirds wheeled above fishing boats.",
"The chemist conducted careful experiments.",
"Garden flowers bloomed in sequence.",
"The musician composed by candlelight.",
"Clouds cast shadows on valley floors.",
"The weaver created intricate tapestries.",
"Tropical fish darted through coral reefs.",
"The historian uncovered forgotten facts.",
"Morning mist clung to valley floors.",
"The glassmaker shaped molten material.",
"Wildflowers dotted alpine meadows.",
"The cartographer drew detailed maps.",
"Ocean waves shaped coastal caves.",
"The potter glazed ceramic vessels.",
"Desert cacti bloomed after rain.",
"The astronomer observed distant stars.",
"Forest creatures stirred at twilight.",
"The mime performed silent stories.",
"Mountain goats traversed steep cliffs.",
"The painter captured fleeting moments.",
"River otters played in swift currents.",
"The botanist preserved rare specimens.",
"Bamboo forests swayed in wind.",
"The sculptor carved marble precisely.",
"Tides changed with lunar phases.",
"The photographer waited for perfect light.",
"Arctic foxes hunted in snow.",
"The composer arranged musical notes.",
"Volcanic steam vented from fissures.",
"The archaeologist brushed away sand.",
"Coral reefs teemed with marine life.",
"The writer edited manuscript pages.",
"Prairie dogs watched for predators.",
"The alchemist mixed mysterious compounds.",
"Ancient glaciers carved valleys deep.",
"The storyteller wove tales together.",
"Desert scorpions hunted at night.",
"The navigator plotted stellar courses."
]
Additional context
I have tested and observed myself on Ubuntu 24.04, Ubuntu 22.04 and Arch linux. Had a friend try on MacOs he observed the same but it seemed less severe, after loading the knowledge he reported his agent settled to around 6gb.
The servers i tried some had 128gb+ ram, and some had <8gb ram that would get OOM killed.
All my tests were done on Node v23.03.0. If someone cant reproduce id love to know node version used.
The text was updated successfully, but these errors were encountered:
Hello @daltoncoder! Welcome to the ai16z community. Thank you for opening your first issue; we appreciate your contribution. You are now a ai16z contributor!
Describe the bug
Every call to this function allocates anywhere between 100-500mb of memory that it never releases. Here is the exact line(in this codebase) the memory is allocated at: https://github.com/elizaOS/eliza/blob/main/packages/core/src/embedding.ts#L302
This is problematic when deploying an agent on an environment that has limited resources, and a character file with a lot of memories to create. Having a lot of knowledge in your character file will instantly get your memory footprint above 10gb and it will stay that high until the process is killed.
Here is the results of inserting a log in every iteration processCharacterKnowledge and inserting 120ish random sentences into the "knowledge" of c3po example character file
After this the memory footprint stayed at around 9.5.gb +- 200mb until i killed the process, and when restarted ran comfortable <2gb memory because the database already had the memories so this was skipped.
As you can see in run 23 and 45 there is a some sort of garbage collection but im not sure what triggers this. But I have even tried exposing v8 gc and forcing collection after memories are inserted, but it didnt help much.
The problem most definitely lies in fastembed but its not obvious. Just thought I would bring this to your attention maybe someone has some ideas
To Reproduce
You can just fill any of the example agents with a lot of knowledge and start it and check your resources. Here is one of random sentences i would add to c3po's knowledge to test
Additional context
I have tested and observed myself on Ubuntu 24.04, Ubuntu 22.04 and Arch linux. Had a friend try on MacOs he observed the same but it seemed less severe, after loading the knowledge he reported his agent settled to around 6gb.
The servers i tried some had 128gb+ ram, and some had <8gb ram that would get OOM killed.
All my tests were done on Node v23.03.0. If someone cant reproduce id love to know node version used.
The text was updated successfully, but these errors were encountered: