[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
how do you write a program that uses all of the RAM in your computer?
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 42
Thread images: 5
File: corememory.jpg (72 KB, 660x495) Image search: [Google]
corememory.jpg
72 KB, 660x495
how do you write a program that uses all of the RAM in your computer? eny examples in C or Python would be nice. just a big malloc()?
>>
>>54586825
while (1) malloc(1):
>>
Use a fork bomb, the old ways never die.
>>
>>54586825
Your OS will most likely kill it after a certain point
>>
File: 1444281326920.png (168 KB, 748x756) Image search: [Google]
1444281326920.png
168 KB, 748x756
It's called Chrome.
>>
>>54586825
I don't have the sources code but check out this program called Windows
>>
>>54586867

kek
>>
>>54586825

if i have X GB or memory, how do i programmatically (C, Python, Assembler) say: grab X GB of RAM?
>>
>>54586990

or rather N GB (where N <X)
>>
make a runnable file with content "./filename"
run it
>>
>>54586990
C:
char *ptr;
ptr = malloc (4294967296 * sizeof (char));
>>
>>54586874
Actually kekd
>>
>>54587025
That's pretty basic.
I think OP is asking how he'd do it dynamically.
Also interested, bump
>>
>>54587120

Then fuck off to ylyl
>>
File: 1288659734001.jpg (20 KB, 244x189) Image search: [Google]
1288659734001.jpg
20 KB, 244x189
Use calloc it'll set it all to zero so that you won't have to bother with memset.
>>
>>54587139

no, statically :) but dynamically would also be nice.

op
>>
>>54587025

does it only work up to 4 GB?

i assume sizeof(char) is one byte
>>
seriously, like
:(){:|:&};:
>>
>>54587288
That'll give you a syntax error
>>
>>54587481
nice try
>>
>>54587515
It's true. Your whitespace is wrong.
>>
>>54587565
when the fuck has whitespace ever mattered in bash in this context?
>>
even with only 2gb of ram ive never really used it all

firefox uses like 500mb max, all my games are old as shit and some use double digit amounts of ram, most intensive thing ive ever done to get close to all 2gb was halo 2
>>
>>54587594
Have you never defined a function in bash?
>>
>>54586874
Underrated post
>>
File: 1438072054450.gif (302 KB, 307x281) Image search: [Google]
1438072054450.gif
302 KB, 307x281
>>54587288
>tfw it doesn't work
>>
>>54586825
#include<stdio.h>
#include<stdlib.h>

int main(){

int i=1;
while(1)
{
int * a = malloc(sizeof(char)*1024*1024);
if(!a) {break;}
else{
printf("%dMB allocated\n",i);
i++;
}
}

return 0;
}
>>
File: 1414961963163.png (142 KB, 2000x2000) Image search: [Google]
1414961963163.png
142 KB, 2000x2000
>>54586874
goodlord
>>
>>54586825
You'll "use up" all the ram with any malloc call or loading in a file that is 8 gigabytes big, but modern day operating systems are intelligent and will just page it so it doesn't affect other processes.

>>54586874
>>54586880
lmao
>>
>>54587025
>sizeof (char)

According to section 6.5.3.4 constraint 4 of ISO 9899, you're a fucking retard.
>>
>>54586825
`yes`

your welcome.
>>
>>54589400
according to constraint 3, you're in over your head
>>
>>54589400
>using ~20 year old standards
>>
>>54586843
>>54587025
>>54589054
Overcommit.
>>
>>54586843
while(malloc(1));
>>
>>54589505
according to n1570 he's still a retard
>>
>>54591148
See >>54590787
>>
>>54591244
strictly speaking, that _will_ work, just not for the reason he thinks.
>>
>>54589054

thx

if i add another printf to print the return value of malloc()

printf("%p foobar\n",a);

how do i interpret the address it returns? for example:

1065MB allocated
0x747fc008 foobar
>>
>>54586867
Fork bombs don't usually fill your ram
>>
>>54586825

I'm pretty sure you can't do that if you're using an operating system like Windows or Linux.

Why do you think memtest86 is it's own operating system.
>>
>>54586874
topkek
You deserve it if you run chrome.
Thread replies: 42
Thread images: 5

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.