Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "memory allocation"
Interviewer: Welcome, Mr X. Thanks for dropping by. We like to keep our interviews informal. And even though I have all the power here, and you are nothing but a cretin, let’s pretend we are going to have fun here.
Mr X: Sure, man, whatever.
I: Let’s start with the technical stuff, shall we? Do you know what a linked list is?
X: (Tells what it is).
I: Great. Can you tell me where linked lists are used?
X:: Sure. In interview questions.
X: The only time linked lists come up is in interview questions.
I:: That’s not true. They have lots of real world applications. Like, like…. (fumbles)
X:: Like to implement memory allocation in operating systems. But you don’t sell operating systems, do you?
I:: Well… moving on. Do you know what the Big O notation is?
X: Sure. It’s another thing used only in interviews.
I: What?! Not true at all. What if you want to sort a billion records a minute, like Google has to?
X: But you are not Google, are you? You are hiring me to work with 5 year old PHP code, and most of the tasks will be hacking HTML/CSS. Why don’t you ask me something I will actually be doing?
I: (Getting a bit frustrated) Fine. How would you do FooBar in version X of PHP?
X: I would, er, Google that.
I: And how do you call library ABC in PHP?
I: (shocked) OMG. You mean you don’t remember all the 97 million PHP functions, and have to actually Google stuff? What if the Internet goes down?
X: Does it? We’re in the 1st world, aren’t we?
I: Tut, tut. Kids these days. Anyway,looking at your resume, we need at least 7 years of ReactJS. You don’t have that.
X: That’s great, because React came out last year.
I: Excuses, excuses. Let’s ask some lateral thinking questions. How would you go about finding how many piano tuners there are in San Francisco?
X: 37. I googled before coming here. Also Googled other puzzle questions. You can fit 7,895,345 balls in a Boeing 747. Manholes covers are round because that is the shape that won’t fall in. You ask the guard what the other guard would say. You then take the fox across the bridge first, and eat the chicken. As for how to move Mount Fuji, you tell it a sad story.
I: Ooooooooookkkkkaaaayyyyyyy. Right, tell me a bit about yourself.
X: Everything is there in the resume.
I: I mean other than that. What sort of a person are you? What are your hobbies?
X: Japanese culture.
I: Interesting. What specifically?
I: What’s hentai?
X: It’s an televised art form.
I: Ok. Now, can you give me an example of a time when you were really challenged?
X: Well, just the other day, a few pennies from my pocket fell behind the sofa. Took me an hour to take them out. Boy was it challenging.
I: I meant technical challenge.
X: I once spent 10 hours installing Windows 10 on a Mac.
I: Why did you do that?
X: I had nothing better to do.
I: Why did you decide to apply to us?
X: The voices in my head told me.
X: You advertised a job, so I applied.
I: And why do you want to change your job?
X: Money, baby!
X: I mean, I am looking for more lateral changes in a fast moving cloud connected social media agile web 2.0 company.
I: Great. That’s the answer we were looking for. What do you feel about constant overtime?
X: I don’t know. What do you feel about overtime pay?
I: What is your biggest weakness?
X: Kryptonite. Also, ice cream.
I: What are your salary expectations?
X: A million dollars a year, three months paid vacation on the beach, stock options, the lot. Failing that, whatever you have.
I: Great. Any questions for me?
I: No? You are supposed to ask me a question, to impress me with your knowledge. I’ll ask you one. Where do you see yourself in 5 years?
X: Doing your job, minus the stupid questions.
I: Get out. Don’t call us, we’ll call you.
All Credit to:
Today, I was told to investigate why the software doesn't work on "some" computers. I had no previous experience with that particular software but I just had to make some tests... easy, right? As soon as I ran the software, my computer crashed (I literally had to restart the pc). I asked my colleagues if I did something wrong but the set up seemed ok.
Later, in a random discussion about the software I found out it does "a little memory allocation". I opened the performance tab in task manager and ran the software again. In an instant, the RAM went from 1.3GB to 7.66GB (my pc has 8GB of RAM).
In an attempt to find how such a monstrosity was creater, I found out the developer that made the software had 16GB of RAM on his pc.
I have found something that eats RAM more than Chrome... brace yourselves.8
Wonder if I'll ever feel like a real programmer in web dev surrounded with C++ gurus that eat, sleep, and breathe memory allocation and optimization algorithms. I'm just over here like... You can go to this link and a pretty red box moves around on the screen27
When valgrind (C Memory allocation error detection tool) aborts due to a memory allocation error...1
Okay, just wrote a program with memory allocation inside an accidental infinite loop and by the time I was able to kill it, it had already claimed 86% of my memory. Scared the shit out of me because my OS was CRAWLING for a while3
I'm a hardware guy. If I do software, it's bare-metal (almost always). I need to fully understand my build system and tweak it exactly to my needs. I'm the sorta guy that needs memory alignment and bitwise operations on a daily basis. I'm always cautious about processor cycles, memory allocation, and power consumption. I think twice if I really need to use a float there and I consider exactly what cost the abstraction layers I build come at.
I had done some web design and development, but that was back in the day when you knew all the workarounds for IE 5-7 by heart and when people were disappointed there wasn't going to be a XHTML 2.0. I didn't build anything large until recently.
Since that time, a lot has happened. Web development has evolved in a way I didn't really fancy, to say the least. Client-side rendering for everything the server could easily do? Of course. Wasting precious energy on mobile devices because it works well enough? Naturally. Solving the simplest problems with a gigantic mess of dependencies you don't even bother to inspect? Well, how else are you going to handle all your sensitive data?
I was going to compare this to the Arduino culture of using modules you don't understand in code you don't understand. But then again, you don't see consumer products or customer-specific electronics powered by an Arduino (at least not that I'm aware of).
I'm just not fit for that shooting-drills-at-walls methodology for getting holes. I'm not against neither easy nor pretty-to-look-at solutions, but it just comes across as wasteful for me nowadays.
So, after my hiatus from web development, I've now been in a sort of internet platform project for a few months. I'm now directly confronted with all that you guys love and hate, frontend frameworks and Node for the backend and whatever. I deliberately didn't voice my opinion when the stack was chosen, because I didn't want to interfere with the modern ways and instead get some experience out of it (and I am).
And now, I'm slowly starting to feel like it was OKAY to work like this.10
> be me
> has some free time
> decides to practice rust skills
> logs on codewars
> finds challenge involving prime numbers
> passes 30 min skimming the Internet to implement the Sieve Of Atkin algorithm
> tries example tests
> submits answer
> “memory allocation of 18446744073709547402 bytes. failederror: process didn’t exit successfully”
> 18446744073709547402 bytes ~= 18 million petabytes
So yeah, I think it’s broken9
The top reasons to become a dev are:
- your brain acutally gets challenged to its fullest
- you can fix most of your IT problems yourself
- you are forced to learn how to deal and live with stress
I won't list the disadvantages, becaus it would result in memory allocation errors.3
You know what just gets to me about garbage-collected languages like c# and Java? Fucking dynamic memory allocation (seemingly) on the stack. Like it's so bizzare to me.
"Hey, c#, can I have an array of 256 integers during run-time?"
"Ya sure no prob"
"What happens when the array falls out of scope"
"I gotchu fam lol"8
Well done, Google Chrome, you ate most of my 16 GB of RAM! >:v
P.D. I said "most of" because of the memory allocation table5
Anyone else taking Harvard's CS50 via edX? It's so awesome! You get a better understanding of Computer Science and stuff. I'm loving C! It feels so close to communicating with the machine. Memory allocation fascinates me, too. Is this why it's fast? If you feel like you're lacking with the CS fundamentals although you can build apps or websites already, I recommend this. This is better than my whole years in college!10
University Coding Exam for Specialization Batch:
Q. Write a Program to merge two strings, each can be of at max 25k length.
Wrote the code in C, because fast.
Realized some edge cases don't pass, runtime errors. Proceed on to check the locked code in the Stub. (We only have to write methods, the driver code is pre-written)
Found that the memory for the char Arrays is being allocated dynamically with size 10240.
Dafuq? What's the point of dynamic Memory Allocation if you're gonna fix it to a certain amount anyway?
Called the Program Incharge, asking him to check the problem and provide a solution. He took 10 minutes to come, meanwhile I wrote the program in Java which cleared all the test cases. <backstory>No University Course on Java yet, learnt it on my own </backstory>
Dude comes, I explain the problem. He asks me to do it in C++ instead coz it uses the string type instead of char array.
I told him that I've already done it in Java.
Him: Do you know Java?
No you jackass! I did the whole thing in Java without knowing Java, what's wrong with you!2
Well I'm a first year student in computer science and in the first semester we started to learn C language and the IDE they told us to use for better learning was Devcpp.
We made a few small projects and all went well, but now in the second semester we started to make bigger projects with linked lists and memory allocation and Devcpp starts to be a complete bug itself... We are working hard in the project and after saving the project with no errors at all, at the next day, Devcpp starts to make any function we made invalid...
So we spoke to the same teacher about this and asked what can we do about it....
"Are you using Devcpp? You shouldn't, it is not that good for C"...
ARE YOU KIDDING ME?14
Annoyance in C: using the same keyword for two unrelated things, process-long memory allocation and internal linkage. Looking at you, static.
The latter should really have been called "intern", just like there is "extern". Far more people would use it if it was named correctly.
History says "static" was chosen for compatibility, allowing older compilers to take new source files.2
I've been using arch for like 2 months now. And I can even play games on it quite smooth (cs and stuff). But I'm missing Witcher 3 and Rise of the Tomb Raider. So I took all my courage and booted into win10. Guess what they welcome me with...
Edit: this was after the 5th reboot. Now I'm getting fucking bsods like nothing because of bad memory allocation :( fuck this shit. Has anybody of you got a working windows PC? I just want to playyyy 😢10
Assignment release: this is a basic assignment that is supposed to help you understand the basics of memory allocation. You are free to use any design you want, however you can implement more advanced features that would lean towards specific designs. What will be punished is that you don't have a dynamic memory allocator. We will run the tests for these offline after the deadline
2 days before the deadline: we released the tests for checking whether you're allocating memory dynamically, but these tests also check for this specific design. So fuck you for choosing any other design than this one. Have fun on sleepless nights.
Fuck me, I guess, for worthlessly working on a different design than they wished for, but didn't specifically ask for from the beginning. I just wasted 2 weeks of my life and feel unmotivated af to do anything anymore regarding this. Fuck this shit. Fuck them. Fuck this course.1
My most humbling experience was finding the source code online to the original Pokemon games. It was right after I had finished my first text based Linux console game and I was looking up other programs source codes just for shits and giggles. Most of them were simple and I learned a few simple tricks but the red and blue Pokemon were the first codes I saw that fascinated me. The addressing, the memory allocation, even the simple audio processing was simply genius. So many unique innovations and techniques. If I achieve 1/5th of the skill I found in those files, I can die a happy programmer!3
I have waitsted whole my day searching a bug with memory allocation in C++, and still don't know how to fix it! That moment, when coding took me far less time than searching that fucking bug... I feel that i missed anything, but all looks ok
I HATE C++ WITH IT'S FUCKING POINTERS!!!!!25
You know shit is going to hit the fan if the sentence "c++ is the same as java" is said because fuck all the underlying parts of software. It's all the fucking same. Oh and to write a newline in bash we don't use \n or so, we just put an empty echo in there. And fuck this #!/bin/bash line, I'm a teacher. I don't need to know how shit works to teach shit. Let's teach 'em you need stdio for printf even tho it compiles fine without on linux (wtf moment number one, asking em leaves you with "dunno..") and as someone who knows c you look at your terminal questioning everything you ever learned in your whole life. And then we let you look into the binaries with ldd and all the good stuff but we won't explain you why you can see a size difference in the compiled files even tho you included stdio in the second one, and all symbol tables show the exact same thing but dude chill, we don't know what's going on either.
Oh and btw don't use different directory names as we do in our examples. You won't find your own path, there is no tab key you can press to auto-fill shit.
But thats not everything. How about we fill a whole semester with "this is how to printf" but make you write a whole game with unity and c#. (not thaught even the slightest bit until then btw)
Now that you half-assed everything because we put you in a group full of fucks who don't even know what a compiler is but want to tell you you don't know shit and show you their non-working unfinished algorithms in some not-even-syntax-correct java...
...how about we finally go on with Algebra II: complex numbers, how they are going to fuck up your life, how we can do roots of negative numbers all of the sudden and let you do some probability shit no one ever fucking needs. BUT WHY DON'T YOU KNOW EVERYTHING ALREADY HMMMMM, IT'S YOUR SECOND LESSON, YOU WENT TO SCHOOL PLS BE A MATH PRO ASAP CUS YOU NEED IT SO MUCH BUT YOU DON'T NEED TO KNOW PROPER SYNTAX, HOW MEMORY MANAGEMENT WORKS, WHAT A REFERENCE IS AND PLS FINALLY FORGET THE WORD "ALLOCATION" IT DOESN'T PLAY A SINGLE ROLE YOU ARE STUDYING SOFTWARE DEVELOPMENT WHY ARE YOU SO BAD AT ECONOMICS IT MAKES NO SENSE I MEAN YOU HAD A WHOLE SEMESTER OF HOW TO GREET SOMEONE IN ENGLISH, MATHS > ECONOMICS > ENGLISH > FUCKING SHIT > CODING SKILL THATS HOW THE PRIORITIES WORK FOR US WHY DON'T YOU GET IT IT MAKES SO MUCH SENSE BRAH4
I always wanted to learn more about C and learn the dark concepts in it. But whenever i search for it ( like.. " Advanced C concepts " ) or find a book , i end up finding dynamic memory allocation and using single dimensional pointers.. Maybe i am searching it all wrong .14
C++. Damn the pointers. It's because I learned Java before C++ and the memory management in C++. I don't get it ever, the object creation, memory allocation, deallocation and everything6
There's something about C that feels very simple and straightforward, it's actually sort of fun to use? I've never used it much before aside of learning some in college. Everything you use syntactically does exactly what it says on the box, for starters. A .NET dev, I am working on getting past the stage where it feels intimidating. Wrote a simple mark-and-sweep garbage collector to learn more about memory allocation.2
I got a phone interview!!! Hope it goes better than my last one :') that one was for a web developer position and they asked me about stack vs queue and memory allocation. Idk why but I sure as shit didn't get the job.2
Compilers should just work for raw C with only static memory allocation. This isn't the bad old days where a couple of dudes wrote a short book explaining how C might probably should possibly work. I hear supposedly we have standards now.
Well, last week I lost 2 days to our compiler randomly forgetting that it wasn't okay to put a globally allocated uint32 at an address ending in 9. What? It had been handling this case without issue for more a year, but now after changing completely unrelated code we have this problem.
I'm not sure how to even deal with this idiocy so no doubt I'll continue working on it this week, too.
Thanks a lot, GCC.1
Fucking gdb with your stupid commands, showing me the memory allocation, shos me the data you stupid piece of shit, what is the value pointed by the pointer.
*Segmentation fault**core dumped*
Oh gdb! How much I missed you. Please don't ever leave me okay?
A game taking place inside an operating system. Like Tron but needs to have much more solid analogies. User's body as tty process. Some representation of scheduler priority and memory allocation. Forking. Children and zombies. Init.
Some process-ownable token representing file handles.
Network ports as portals through which data may be sent by acquiring a file handle and using it.
/proc, /mem, etc are extreme stretch goals.
Never really started because I couldn't decide how to represent all the different parts so they would all be consistent *and* entertaining
As an extension of the extreme stretch goals, a multiplayer functionality where players can shell into each other's game worlds ("computers")
Why somebody would think that allocate huge amount of objects in the static memory make any sense?? Why??? You need to allocate a bloody database context and all the allocation of your IOC containers and keep increasing!!!
Why TF does nodejs just eats 100mb of ram away for a simple application with ONE websocket connection ? I've tried getting some heap snaps, memory allocation timelines and used memwatch-next, but to no result AT ALL! Since the heap stay small but the rss memory grows like there is no tomorrow.
1) Reader Rabbit on an Apple IIGS in the late 80s. I might've been in Kindergarten. Found the boxes stored in an unreachable storage area at my dad's house recently. Knowing how he took care of things, it probably still works. He won't let me touch it.
2) Fast forward to early middle school, Ultima VII on an NEC desktop, 90s. That game was great but also a pain in the ass. Had to make a startup floppy disk to help with memory allocation and something else. Learned DOS things. For some reason the disk wouldn't work from one day to the next so would have to reconfigure it frequently. Also learned the hard way not to fork too much with autoexec.bat during this period.
I have a love hate relationship with C honestly. I hate that you have to do so much overhead management and control of all of your pointers and arrays and manually handle memory allocation and management, but on the other hand it's pretty cool to work that low / close to the machine code and the programs run lightning quick. Pros and cons, I guess. Would've been interesting to be around in the early days..1
!rant That feeling you get when you run through your code perfectly after fixing the memory de/allocation :D So rewarding!
Today was all about dynamic memory allocation. I spent my whole day researching and learning this topic. I had watched couple of videos before I got to bed. Just a while ago I had a dream where Bucky Roberts from thenewboston and David J Malan were instructing me. Wow, such a nice dream.
I have a personal opinion and correct me if I'm wrong
Why does a programmer need to learn behind the scenes stuff (memory allocation).
I know it helps to understand the concepts better.
Why would I learn how the engine of a car works in order to drive a car ?.
And the only task is required from you to drive a car.
And literally you can code without knowing any of these stuff and since companies only need clean and efficient code.
Will it be really helpful to enhance your coding skills if you know behind the scenes stuff ?7
Just realized a member function pointer can be a template parameter as non-type, gonna try to use it do no dynamic memory allocation trick with std::function.