www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GC don't understand

reply Nahon <lburger hu.tesco-europe.com> writes:
Hi.

I'm developing a web server application using threads and sockets. It's quite
simple but it throws "Error: Access Violation" and stops responding for
incoming connections very frequently. When it occurs I have to Ctrl-C the
server and restart to continue its work. I've put tons of debug info to trace
the error but I've found no order on where it throws. So for a try I disabled
the GC and now it works as it should.
Why does this happen? How could I re-enable the GC (memory consuming is
increasing by every connection) without having to fear of Access Violation
errors?

Regards,
Nahon
Nov 14 2006
parent reply Daniel Keep <daniel.keep.lists gmail.com> writes:
Nahon wrote:
 Hi.
 
 I'm developing a web server application using threads and sockets. It's quite
 simple but it throws "Error: Access Violation" and stops responding for
 incoming connections very frequently. When it occurs I have to Ctrl-C the
 server and restart to continue its work. I've put tons of debug info to trace
 the error but I've found no order on where it throws. So for a try I disabled
 the GC and now it works as it should.
 Why does this happen? How could I re-enable the GC (memory consuming is
 increasing by every connection) without having to fear of Access Violation
errors?
 
 Regards,
 Nahon

Access Violations can be caused by a few things. One of these is attempting to use a null object, but it doesn't sound like that. The other is attempting to use an object that's been deleted. D's GC should never delete an object you still have a reference to; are you deleting objects manually? If so, that could be your problem: you're deleting an object and then trying to use it again. It's really the only thing I can think of at the moment; sorry. -- Daniel -- Unlike Knuth, I have neither proven or tried the above; it may not even make sense. v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP http://hackerkey.com/
Nov 15 2006
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Daniel Keep wrote:
 
 Nahon wrote:
 Hi.

 I'm developing a web server application using threads and sockets. It's quite
 simple but it throws "Error: Access Violation" and stops responding for

Access Violations can be caused by a few things. One of these is attempting to use a null object, but it doesn't sound like that. The other is attempting to use an object that's been deleted.

Could also be because you're passing D char[]'s to C functions that expect char*. Any time you call a C function that takes a string, you need to call toStringz() on it. --bb
Nov 15 2006