Manual Memory Management and Automatic Garbage Collection

  • Thread starter Tridib Bandopadhyay
  • Start date
R

Robert Klemme

I have some questions::--

1. Is it possible to Manually free memory(without calling GC.start) by
extending it with C? As i have tried it and its of no use for my work.

2. Can I add a new file and try to manually free memory(disabling GC)?

I am sure, both can be achieved with an amount of hacking Ruby's
source code. So: yes and yes.

What I do not understand: what is the aim of your research? I mean,
people have spent numerous hours of research and engineering to make
automatic GC work, and you seem to be mainly concerned with adding
manual memory management to a language which has automatic GC. What
is the point of your research?

Kind regards

robert
 
T

Tridib Bandopadhyay

Robert K. wrote in post #999427:
I am sure, both can be achieved with an amount of hacking Ruby's
source code. So: yes and yes.

What do you mean by Hacking Ruby's Code... I didn't get it.. Can you
describe me in Detail.
What I do not understand: what is the aim of your research? I mean,
people have spent numerous hours of research and engineering to make
automatic GC work, and you seem to be mainly concerned with adding
manual memory management to a language which has automatic GC. What
is the point of your research?

Kind regards

robert


Yeah i know that.. But since Ruby is Using Stop the World concept. So I
was thinking of not letting the GC to come and free memory every time
for small objects,Stopping the code. So I just want to check if it can
be helpful or not...

Thanks...

Regards

Tridib
 
P

Phillip Gawlowski

What do you mean by Hacking Ruby's Code... I didn't get it.. Can you
describe me in Detail.

% svn co http://svn.ruby-lang.org/repos/ruby/trunk ruby
% cd ruby
% vim ruby.c gc.c
# modify Ruby's source code here.
Yeah i know that.. But since Ruby is Using Stop the World concept. So I
was thinking of not letting the GC to come and free memory every time
for small objects,Stopping the code. So I just want to check if it can
be helpful or not...

Then start looking at other GC systems that are used by other
languages. You don't know if you can improve Ruby's GC if you don't
know about other GCs, and how they are implemented, no?

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
J

JK Victor

Tridib Bandopadhyay wrote in post #999550:
So I
was thinking of not letting the GC to come and free memory every time
for small objects,Stopping the code. So I just want to check if it can
be helpful or not...

Ruby has a very primitive conservative GC -- it just scans the stack
looking for pointers. If you are a time traveler from the 1950s then
Ruby's GC might be an interesting study.

In any case it would be easy to fool Ruby's GC, if that's what you wish:
allocate a pointer and hide data behind the pointer. The GC won't see
pointers which aren't on the stack. You can manage that GC-concealed
data however you like.
 
R

Robert Klemme

Robert K. wrote in post #999427:
Yeah i know that.. But since Ruby is Using Stop the World concept. So I
was thinking of not letting the GC to come and free memory every time
for small objects,Stopping the code. So I just want to check if it can
be helpful or not...

Did you mean to include manual cleanup of particular instances which
are known to be not used any more (e.g. when a method is left)? In
that case keep in mind that it is hard to know which objects can be
collected because you do not know what other objects local variable
hold or create and you also do not know whether references of objects
in local variables are published somewhere else so they have to live
longer than the stack frame where their local variable reference is
stored.

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
T

Tridib Bandopadhyay

Thank you all for replying

What I am trying to achieve is I will allocate some 3 Bytes(for
example).. And will free that space by myself and will not bother
Garbage Collector to worry for that.I know the Ruby GC is coded in such
a way which will be helpful to the users but I want to check how much
difference it can cost if it had Manual Memory Deallocation.

Secondly, Can I call GC.start() from other file like.. within sqrt()
function in Math.c, Can I call it?If so, What is the syntax for calling
it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top