Citrix System Inc Interview Question for Software Engineer / Developers


Country: India
Interview Type: Phone Interview




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

Basically, there are two way to do automatic garbage collection. First of all, only objects in the heap require garbage collection. Objects in stack are automatically cleaned once the function/program goes out of scope, objs in heap are not cleaned automatically.
1. Use reference counting i.e whenever a object is created, we also keep a count of number of pointers referring to that object called the reference count. Then, if the reference count become zero i.e. we have no pointer pointing to that object, we can safely release the memory. A good example of this is the shared/unique/weak pointers in C++ STL
2. We periodically do garbage collection i.e. after some interval a garbage collector runs and any unreferenced memory objects are freed. A good example is Java. Basically, we start from a set of base objects (say all objects in the stack), follow the references and mark any object we encounter on the way as ok. Then we sweep the entire heap again and any object found not marked is unreachable and therefore can be freed.

- puneet.sohi December 03, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you are using Java as the coding language then one thing you can do, is to make sure that the objects after use should be made to point to null. The garbage collector make sure that the object which are null , the memory related to them on the heap will be free. So the best way to make a garbage collector is to make the object null after the use.

- pratikpalashikar January 01, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If you are using Java as the coding language then one thing you can do, is to make sure that the objects after use should be made to point to null. The garbage collector make sure that the object which are null , the memory related to them on the heap will be free. So the best way to make a garbage collector is to make the object null after the use.

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

Question is about how to create your own garbage collector not how it works

- Anonymous January 03, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Question is about how to create your own garbage collector not how it works

- Prasanna January 03, 2017 | Flag Reply


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