C

The sizeof operator can be used to

printf("%lu", sizeof(double));
printf("%lu", sizeof(double *));

It can also be used on a variable:

int x = 7;
pritnf("%lu", sizeof(x));

If you use the sizeof operator on an array, you will see that the memory is exactly the size of an element times the number of elements. There is no overhead:

int y[10];
printf("%lu", sizeof(y));

structs

unions

C++

objects

Java

Memory usage for Java types on a 64-bit architecture:

type bytes
boolean 1
byte 1
char 2
int 4
float 4
long 8
double 8
reference 8
objects 16 + (size of instance variables, rounded up to multiple of 8)
array 24 + (size of element) * (number of elements)

Python

JavaScript

Data Structures

  • list
  • stack
  • queue
  • heap
  • disjoint-set data structure
  • hash table