question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mitigating memory issues related to in memory storage

See original GitHub issue

I might actually have an idea that could mitigate the problem with storing files in memory.

The problem currently is that the program needs to allocate twice the space for each file. This is because chunks comes from the browser and emits a data-event. We then store an array of all of these chunks. When this is done, the array takes up roughly as much memory as the file.

But then we do Buffer.concat(array) to create a new buffer with all of the chunks, and this creates another buffer that takes up roughly the same size as the file again.

Now, I’m not 100% sure that this is the only problem. There might be places where buffers actually gets retained longer but this is at least on problem we have.

I believe that in memory store should only be used when you expect small files, small enough to be allocated straight in the memory. (That is, all the parts in line, as a Buffer is)

What we could do is allocate one Buffer for the entire body with the size of the initial Content-Length header. Then copying in to that one buffer, and whenever we have a part, just slice that one of.

Buffer#slice returns a new buffer that points to the same actual bytes, so this would avoid allocating all files twice.

This change would require quite much reengineering and I don’t even think it’s feasible to build it upon busboy. I think that this isn’t high priority but it’s worth to keep in mind.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusUcommented, Jul 17, 2015

This issue is regarding the memory storage. You can’t upload 30GB of video to the memory on the server and not expect it to take up memory.

If you are having this problem with disk storage you’ll have to open another issue.

0reactions
brown2rlcommented, Jun 11, 2016

Thanks!

-----Original Message----- From: “Cybrary” donotreply@cybrary.it Sent: ‎6/‎11/‎2016 10:09 AM To: “robert.brown@ieee.org” robert.brown@ieee.org Subject: Python, Web App Pentesting & Social Media: Essential Resources for Every Professional

Explore Cybrary: June 11
View this email in your browser

Your Saturday Cartoon! And a Cybersecurity fun-fact.

FACT:10 percent of social media users have received a cyber-threat. More than 600,000 accounts are compromised every day on Facebook alone.

Want more? See what other info Hexis Cyber Solutions has.

Coming Soon:

Upcoming S3SS10N Wednesday: Block Cyphers vs. Stream Cyphers by Kelly Handerhan Coming June 15th Miss last week’s S3SS10N? View it here.

Web App Penetration Testing - Coming Tuesday, June 14th Cybrary’s newest course by Raymond Evans will be available in just 3 days! Stay tuned for the release - you won’t be disappointed.

Other Bits & Pieces:

Even professionals need practice. Review from our list of amazing tutorials and other resources.

Google Dorking Guide

“Done for You” - The Complete List of Kali Linux & Linux Training Videos on Cybrary

How Can I Become A H@cker?

Interested in in-depth Python tutorials? Primal Security has nearly 20 tutorials waiting to be read and watched! Check out part 1 of their series here, or find the one you want on their channel.

Copyright © 2016 Cybrary, All rights reserved. You’re receiving this message because you became a member of Cybrary IT.

Our mailing address is:

Cybrary 7833 Walker Drive, Suite 510 Greenbelt, MD 20770

Add us to your address book

Want to change how you receive these emails? You can update your preferences or unsubscribe from this list

Read more comments on GitHub >

github_iconTop Results From Across the Web

The mitigating effect of repeated memory reactivations on ...
Memory reactivation is a process whereby cueing or recalling a long-term memory makes it enter a new active and labile state.
Read more >
Delaying memory decline: different options and emerging ...
Memory decline can be a devastating disease and increases in aging Western populations. Memory enhancement technologies hold promise for ...
Read more >
4. Mitigating Memory-Safety Vulnerabilities - Computer Security
The only way to prevent all memory safety exploits is to use a memory-safe language. Instead, these mitigations are best thought of as...
Read more >
8 causes of short-term memory loss and how to combat it
Malnutrition, brain injuries, aging, and lack of sleep can all cause short-term memory loss. Short-term memory loss is common and strikes often.
Read more >
9 Ways to Alleviate Your Memory Problems | Psychology Today
Strategies for improving memory problems resulting from disease or trauma · 1) Cognitive Therapy (CT) and Cognitive Behavioral Therapy (CBT) · 2) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found