NVIDIA Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
1
of 1 vote

Malloc would simply start failing when it can no longer allocate more memory. The program will continue to run...

- Lokesh October 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

stack overflow cant occur malloc uses heap :)

- cunomad August 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

awesome ans.
It silently return NULL if memory is not their in heap

- kim July 16, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

seems to be allocating the mentioned amount of memory on heap, but then the while loop keeps moving for-ever so eventually there wont be space to be allocated any more, and then for crossing the threshold amount of heap the process would be killed by OS.

- donkeyMan August 12, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

it give compiler error because malloc return void pointer

- sainiharikesh August 25, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

The size of the process keeps on growing(ps -fl) and the pgm crash when it runs out of memory

- Maankutti September 11, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Program shouldn't crash.... Its an infinitely loop. The behavior depends up on platform. A simple x86 would run indefinitely.

- Vyas September 17, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Malloc would simply start failing when it can no longer allocate more memory. The program will continue to run...

- Lokesh October 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you explain it again .....

- hell June 14, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Malloc would start to return NULL after the exhaustion of the virtual addresses for the process.

- Guruprasad October 16, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. memory lean- you can't track the memory assigned (pointer not available)
2. prog will return null after no memory is available

- anon November 23, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This would cause an infinite loop. There would be no stack overflow. Once the heap is used up, malloc will start returning a null pointer. Some implementations of malloc will complain to stderr, but I don't know if this is implementation dependent or standard.

- Anonymous May 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main (){
int *p;
while(1){
p=(int *)malloc(1024*1024);
if(!p)
printf("no more\n");}
}

output:
aftr some time
no more
no more

no more
.....

so programm will be moved infinite time

- ridercoder October 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

on linux OOM-killer will probably kill that process.

- Anonymous September 10, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

yeah....malloc after some time start returning NULL

- Anonymous December 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

dead loop of leak, till system can not long allocate memory

- Anonymous July 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

error in C++... not implicitly typecasted
works fine in C..implicitly typecasted

- rampurearun September 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

error in C++... not implicitly typecasted
works fine in C..implicitly typecasted

- rampurearun September 18, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ideone.com/ZdH0v

- anon September 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ideone.com/ZdH0v
no overflows exist. as malloc allocate memory to heap..it return null if the specified memory is not in heap.

- Anonymous September 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More