Maybe it's time to put together an instrumented GC...
Wishlist:
- some way to know _when_ a collection happened (or how often)
- logging of allocations (module/linenumber of allocator, size of
allocation, type of allocation)
- per TypeInfo allocation statistics
- per module allocation statisti
Sean Kelly wrote:
> ...
>
> At this point it's quite possible that you still have a reference to
> newData in a register. If you want to be sure the collect call below
> works as intended for this test, try adding:
>
> newData = new Data;
>
> here.
Debugging it with ddbg under Win
Wild guess: there's a false pointer, that keeps one element in the list
from being collected, and because the list-prev pointers are still
there, all following elements won't be collected either in consequence.
If I had time, I'd try two experiments:
1. before freeing everything, reset the prev
Sean Kelly wrote:
At this point it's quite possible that you still have a reference to
newData in a register.
That argument works for one iteration, but this fool just keeps on
growing. Also, this is a pared down test from a much larger program, so
this is unlikely.
If you want to be sure
Robert Fraser wrote:
Simpler version, sans printf:
module leak;
import tango.core.Memory;
struct Data
{
Data* prev;
char[4092] something;
}
public void main()
{
Data* data;
Data* newData;
int i;
while(true)
{
for(i = 0; i < 10_000; i++)
{
Simpler version, sans printf:
module leak;
import tango.core.Memory;
struct Data
{
Data* prev;
char[4092] something;
}
public void main()
{
Data* data;
Data* newData;
int i;
while(true)
{
for(i = 0; i < 10_000; i++)
{
newData = new Data;
Hello Sam,
Hello,
For the given example below,
E1:
template Chain(R...) if (allSatisfy!(isInputRange, R))
{
static if (R.length > 1)
alias ChainImpl!(R) Chain;
else
alias R[0] Chain;
}
Q1: What's *if* statement doing right after the template definite?I
can guess what the purpose is but I can n
Running this program with Tango SVN + DMD 1.045 or Tango 0.98 + DMD
1.041 on WinXP SP3 32-bit results in a memory leak (the program keeps
increasing in size at every iteration)
leak.d:
---
module leak;
import tango.stdc.stdio;
import tango.core.Memory;
Hello,
For the given example below,
E1:
template Chain(R...) if (allSatisfy!(isInputRange, R))
{
static if (R.length > 1)
alias ChainImpl!(R) Chain;
else
alias R[0] Chain;
}
Q1: What's *if* statement doing right after the template definite?I can guess
what the purpose is
Hi all,
i want to declare an invariant interger, for instance "invariant int x = 3;".
But i've got this error while compiling.
Error: constant 3 is not an lvalue
could someone explain me what's wrong here ? I'm using dmd 2.030
> Dear Saaa, these varargs suck badly and you shouldn't use them. It's so
> simple to introduce portability errors or heisenbugs, and it's
heisenbugs :)
> incredibly hard to get it right. You're better off with alternatives.
>
> Alternative 1: Typesafe Variadic Functions
> Useful if the variadic a
>>
>
> You get an AV because you're passing the argument by value. You need to
> pass its address instead.
>
> Try this:
>
> void main() {
> int i;
> get(file, "i", &i);
> writeln(i);
> }
>
> It will print "7".
Ah of course, thanks.
Dear Saaa, these varargs suck badly and you shouldn't use them. It's so
simple to introduce portability errors or heisenbugs, and it's
incredibly hard to get it right. You're better off with alternatives.
Alternative 1: Typesafe Variadic Functions
Useful if the variadic arguments should have on
Saaa Wrote:
> >
> > import std.stdarg;
> >
> > assert( _arguments[0] is typeid(int*) );
> > auto arg = va_arg!(int*)(_argptr);
> > *arg = 10;
> >
> > Probably.
> >
> > -- Daniel
>
> Calling the following returns an Access Violation Error after
> correctly writing the two lines.
>
> void main()
"Georg Wrede" wrote in message
news:guc6ep$2im...@digitalmars.com...
> Saaa wrote:
> Steven Schveighoffer wrote:
>>> i.e. I want thread 1 to initialize elements 0, 1, and 2, and thread 2 to
>>> initialize elements 3, 4, and 5:
>>>
>>> thread1 = new ProcessingThread(arrayToInit[0..3]);
>>> threa
>
> import std.stdarg;
>
> assert( _arguments[0] is typeid(int*) );
> auto arg = va_arg!(int*)(_argptr);
> *arg = 10;
>
> Probably.
>
> -- Daniel
Calling the following returns an Access Violation Error after
correctly writing the two lines.
void main()
{
int i;
get( file, `i`, i);
}
public void
Saaa wrote:
Steven Schveighoffer wrote:
i.e. I want thread 1 to initialize elements 0, 1, and 2, and thread 2 to
initialize elements 3, 4, and 5:
thread1 = new ProcessingThread(arrayToInit[0..3]);
thread2 = new ProcessingThread(arrayToInit[3..6]);
thread1.start();
thread2.start();
Should be co
>>>
I probably should have phrased my question better with the array, what
I
was
wondering is if it was safe for say two threads to right to the array
at
the same
time as long as I'm sure they're not writing to the same index of the
array?
>>>
>>> You can d
On Tue, 12 May 2009 10:12:48 -0400, Saaa wrote:
I probably should have phrased my question better with the array, what
I
was
wondering is if it was safe for say two threads to right to the array
at
the same
time as long as I'm sure they're not writing to the same index of the
array?
>
>> I probably should have phrased my question better with the array, what I
>> was
>> wondering is if it was safe for say two threads to right to the array at
>> the same
>> time as long as I'm sure they're not writing to the same index of the
>> array?
>
> You can do anything you want withou
On Tue, 12 May 2009 05:11:49 -0400, Brok3n Halo
wrote:
I probably should have phrased my question better with the array, what I
was
wondering is if it was safe for say two threads to right to the array at
the same
time as long as I'm sure they're not writing to the same index of the
arra
Saaa wrote:
> ...
>> var_arg!(T) will convert _argptr into the type you specify and it will
>> also advance _argptr to the next argument.
> What would happen if you'd cast it incorrectly if it wasn't a simple pointer
> ? :D
Same as would happen if you incorrectly cast anything.
i.e. anything.
"Daniel Keep" wrote in message
news:gubip2$187...@digitalmars.com...
>
>
> Saaa wrote:
>> I just noticed D1 does have std.stdarg.
>> I shouldn't just search on the website :(
>> (where it is missing on the phobos page)
>>
>>> import std.stdarg;
>>>
>>> assert( _arguments[0] is typeid(int*) );
>>
Saaa wrote:
> I just noticed D1 does have std.stdarg.
> I shouldn't just search on the website :(
> (where it is missing on the phobos page)
>
>> import std.stdarg;
>>
>> assert( _arguments[0] is typeid(int*) );
>> auto arg = va_arg!(int*)(_argptr);
>> *arg = 10;
>>
>> Probably.
> :D
>> -- Dani
I just noticed D1 does have std.stdarg.
I shouldn't just search on the website :(
(where it is missing on the phobos page)
> import std.stdarg;
>
> assert( _arguments[0] is typeid(int*) );
> auto arg = va_arg!(int*)(_argptr);
> *arg = 10;
>
> Probably.
:D
>
> -- Daniel
So, you make arg point to
Saaa wrote:
>> Saaa wrote:
>>> ...
>>> Passing variadic arguments as ref I think is what I am asking for :)
>> You can't. You have to explicitly take the address of the arguments.
>>
>> -- Daniel
>
> Like this ?
> *_argptr = 10;
> :D
>
> I don't know how to tell the compiler I want to write d
I have never used threads before, but it sounds safe to me as when the
thread gets thrown of the core and later gets back nothing referred by the
register has changed.
Again, I am a newbie :)
"Brok3n Halo" wrote in message
news:gubegl$uu...@digitalmars.com...
>I probably should have phrased my
> Saaa wrote:
>> ...
>> Passing variadic arguments as ref I think is what I am asking for :)
>
> You can't. You have to explicitly take the address of the arguments.
>
> -- Daniel
Like this ?
*_argptr = 10;
:D
I don't know how to tell the compiler I want to write data there.
I probably should have phrased my question better with the array, what I was
wondering is if it was safe for say two threads to right to the array at the
same
time as long as I'm sure they're not writing to the same index of the array?
Also I'm still getting the "Error: Win32 Exception" with my t
Saaa wrote:
> ...
> Passing variadic arguments as ref I think is what I am asking for :)
You can't. You have to explicitly take the address of the arguments.
-- Daniel
30 matches
Mail list logo