In this section we will use the file nodejs/bench_mem.js, tests are run on Node.js v16.14.2 from NVM, Ubuntu 21.10, on Lenovo ThinkPad P51 (2017) which has 32 GB RAM.
Related answer: stackoverflow.com/questions/12023359/what-do-the-return-values-of-node-js-process-memoryusage-stand-for/72043884#72043884
First using
topp
from stackoverflow.com/questions/1221555/retrieve-cpu-usage-and-memory-usage-of-a-single-process-on-linux/40576129#40576129 let's observe the memory usage of some baseline cases.For a Node.js infinite loop nodejs/infinite_loop.jsThis gives approximately:
topp infinite_loop.js
- RSS: 20 MB
- VSZ: 230 MB
Adding a single hello world to it as in nodejs/infinite_hello.js and running:leads to:We understand that Node.js preallocates VSZ wildly. No big deal, but it does mean that VSZ is a useless measure for Node.js.
topp infinite_hello.js
- RSS: 26 MB
- VSZ: 580 MB
Forcing garbage collection as in nodejs/infinite_hello.js brings it down to 20 MB however:
topp node --expose-gc infinite_hello_gc.js
Finally let's see a baseline for which gives initially:but after a few seconds randomly jumps to:so we understand that
process.memoryUsage
nodejs/infinite_memoryusage.js:node --expose-gc infinite_memoryusage.js
{
rss: 23851008,
heapTotal: 6987776,
heapUsed: 3674696,
external: 285296,
arrayBuffers: 10422
}
{
rss: 26005504,
heapTotal: 9084928,
heapUsed: 3761240,
external: 285296,
arrayBuffers: 10422
}
First a baseline case with an array of length 1:This gives the same results as with:
node --expose-gc bench_mem.js n 1
node --expose-gc infinite_memoryusage.js
. The same result is obtained by doing:a = undefined
node --expose-gc bench_mem.js dealloc
If we use we see that the memory is now, unsurprisingly, accounted for under Results for different N:We see therefore that typed arrays are much closer to what they advertise (4 bytes per element), even for smaller element counts, as expected.
Int32Array
typed array buffers instead of a simple Array
:node --expose-gc bench_mem.js array-buffer n N
arrayBuffers
, e.g. for N
1 million:{
rss: 31776768,
heapTotal: 6463488,
heapUsed: 3674520,
external: 4285296,
arrayBuffers: 4010422
}
|| N
|| `arrayBuffers`
|| `rss`
|| `rss` per elem
| 1 M
| 4 MB
| 31 MB
| 5
| 10 M
| 40 MB
| 67 MB
| 4.6
| 100 M
| 40 MB
| 427 MB
| 4
Now let's try one million objects of type gives:Disaster! Memory usage is up to 70 MB! Why?? We were expecting only about 24, 4 baseline + 2 * 10 for each million int?!
{ a: 1, b: -1 }
:node --expose-gc bench_mem.js obj
{
rss: 138969088,
heapTotal: 105246720,
heapUsed: 70103896,
external: 285296,
arrayBuffers: 10422
}
And now an equivalent version using gives the same result.
class
:node --expose-gc bench_mem.js class
Let's try Array:is even worse at 78 MB!! OMG why.
node --expose-gc bench_mem.js arr
{
rss: 164597760,
heapTotal: 129363968,
heapUsed: 78117008,
external: 285296,
arrayBuffers: 10422
}
Each side is a sphere section. They don't have to have the same radius, they are still simple to understand with different radiuses.
The two things you have to have in mind that this does are:
- This is for example why you can use lenses to burn things with Sun rays, which are basically parallel.Conversely, if the input is a point light source at the focal length, it gets converted into parallel light.
- image formation: it converges all rays coming from a given source point to a single point image. This amplifies the signal, and forms an image at a plane.The source image can be far away, and the virtual image can be close to the lens. This is exactly what we need for a camera.
Mitochondria have DNA because they need to be controlled individually by
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
Argued at Power, Sex, Suicide by Nick Lane (2006) page 212.
Basically, energy supply has to be modulated rather quickly, because we spend a lot sometimes, and very little other times.
Even not turning it off quickly enough is a problem, as it starts to generate free radicals which fuck you up.
If control came from the nucleus, it has no way to address different mitochondria. But it might be that only one of the mitochondria needs the change. If the nucleus tells all mitochondria to stop producing when only one is full, the others are going to say: "nope, I'm not full, continue producing!" and the one that need to stop will have its signal overridden by the others.
Special-purpose acquisition company by
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
This is some fishy, fishy business.
Why do multiple electrons occupy the same orbital if electrons repel each other? by
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
As shown at Schrödinger equation solution for the helium atom, they do repel each other, and that affects their measurable energy.
This changes however at higher orbitals, notably as approximately described by the aufbau principle.
The first chapter of the New Testament.
ELF Hello World Tutorial
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
.text
section by Now that we've done one section manually, let's graduate and use the
readelf -S
of the other sections: [Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 2] .text PROGBITS 0000000000000000 00000210
0000000000000027 0000000000000000 AX 0 0 16
.text
is executable but not writable: if we try to write to it Linux segfaults. Let's see if we really have some code there:objdump -d hello_world.o
hello_world.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <_start>:
0: b8 01 00 00 00 mov $0x1,%eax
5: bf 01 00 00 00 mov $0x1,%edi
a: 48 be 00 00 00 00 00 movabs $0x0,%rsi
11: 00 00 00
14: ba 0d 00 00 00 mov $0xd,%edx
19: 0f 05 syscall
1b: b8 3c 00 00 00 mov $0x3c,%eax
20: bf 00 00 00 00 mov $0x0,%edi
25: 0f 05 syscall
If we grep
b8 01 00 00
on the hd
, we see that this only occurs at 00000210
, which is what the section says. And the Size is 27, which matches as well. So we must be talking about the right section.The most interesting part is line to pass the address of the string to the system call. Currently, the This modification is possible because of the data of the
a
which does:movabs $0x0,%rsi
0x0
is just a placeholder. After linking happens, it will be modified to contain:4000ba: 48 be d8 00 60 00 00 movabs $0x6000d8,%rsi
.rela.text
section. ELF Hello World Tutorial Dynamic linking sections by
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
Why do the electron and the proton have the same charge except for the opposite signs? by
Ciro Santilli 37 Updated 2025-07-01 +Created 1970-01-01
Given the view of the Standard Model where the electron and quarks are just completely separate matter fields, there is at first sight no clear theoretical requirement for that.
As mentioned e.g. at QED and the men who made it: Dyson, Feynman, Schwinger, and Tomonaga by Silvan Schweber (1994) chapter 1.6 "Hole theory", Dirac initially wanted to think of the holes in his hole theory as the protons, as a way to not have to postulate a new particle, the positron, and as a way to "explain" the proton in similar terms. Others however soon proposed arguments why the positron would need to have the same mass, and this idea had to be discarded.
Notably used for communication with submarines, so in particular crucial as part of sending an attack signal to that branch of the nuclear triad.
There are unlisted articles, also show them or only show them.