|
The slow operations are rare, at most 1 in 10,000 operations, probably less frequent than that. How would I track this down with a profiler?
Given the nature of the code it does not seem likely that exceptions are being thrown in its midst. There are some calls to the base class library but these use things like List<t> and do not seem likely to involve exceptions.
|
|
|
|
|
A s h wrote: I have verified that no garbage collections occur during these long operations
In this case, it could be linked to Windows memory management. I do not know if you
allocate large blocks of memory, or a lot of small blocks. When you ask for memory,
windows will try not to allocate it. If you actually use the memory, that will cause
a page fault and windows will either create a new page, or swap one from the disk
(depending on the situation).
If you want your system to be under tight constraints, you might have to (try to) manage the
memory yourself.
|
|
|
|
|
The class does small to medium size allocations, generally 32-1000 bytes at a time. The class implementation does a bit of custom memory management in the sense that it maintains a pool of objects for one type of commonly used object.
The class runs completely in managed code and I am not willing to change that - this is a general-purpose library-style implementation of a data structure (with essentially the same interface as ystems.Collection.Generic.Dictionary) that is intended for use within managed or unmanaged programs. The test framework does use the WIN32 API to do timing measurements. That is the only part of the test framework that runs in unmanaged code.
The amount of time used during these slowdowns is on the order of .02 seconds. Sorry for not mentioning this explicitly in the original post. This amount of time seems orders of magnitude too large to be accounted for by page faults. What do you think?
|
|
|
|
|
You should take a look at:
http://blogs.msdn.com/ricom/[^]
Also you could search for "GC mid-life crisis", that would give you pointers to
more details on how the Garbage collector works, and interactions with the OS.
|
|
|
|
|
Thanks.
I think I know what the slowdown is due to - it is probably due to JITting. Now, if I knew how to force the compiler to JIT everything without having to do it in an ad-hoc way like running the benchmark twice..
-- modified at 17:34 Tuesday 5th December, 2006
|
|
|
|
|
hi
i have question about creating subdomain name
if i have domain name is http://www.site.com
i just need to know how to create http://myname.site.com in C#
thanks
|
|
|
|
|
No, you need a DNS record for that.
|
|
|
|
|
Hi, I am wondering if there is a way to create a function in webservices to upload a file without using visual studio2005 designer. I don't want to use microsoft FileUpload controller.
thanks
|
|
|
|
|
A webservice can just be written to take a byte array. Do you mean a web service ? The FileUpload controller lives in a web page, not a web service.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thanks for your answer, Well, I have seen uploading a file through microsoft fileupload controller.
That was ready made controller provided to us and used all the method and properties to upload a file on the desired destination.
Can we get the same functionality while doing the backhand or core prgramming. I want my webservice to upload a file based on the parameter it receives like: public void myupload(string fileFrom,FileTo);.
How can we do?
thanks
|
|
|
|
|
You can't. A web service needs to be passed a byte[] representing the file, not a file path. A fat client program can provide this, as can a web page, but the web page needs to use the Microsoft conrol, a standard HTML one, or a third party alternative.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
hi all
since i can't describe my problem well, plz check this code,
in this code i can sort the list for the x variable -this is fine and working-
but wat if i want also to be able to sort the list with y variable as well.
i can only use IComparable.Compare with x, i want also to be able to sort the list for y variable
how can i do that????
thanks in advance
how can i do that
using System;
using System.Collections;
using System.Collections.Generic;
public class SamplesArrayList
{
public class Test : IComparable
{
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public Test(int x)
{
this.x = x;
}
int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
}
public static void Main()
{
ArrayList test = new ArrayList();
Test l1 = new Test(7);
Test l2 = new Test(3);
Test l3 = new Test(9);
Test l4 = new Test(2);
Test l5 = new Test(4);
test.Add(l1);
test.Add(l2);
test.Add(l3);
test.Add(l4);
test.Add(l5);
test.Sort();
}
}
|
|
|
|
|
yosif4444 wrote: int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
Your compare to can do whatever you like. You return an int, which specifies how far apart two items are, and in what direction. If you want to sort for y within x, then this would work:
if (x == x1.x)
{
return y - x1.y);
}
else
{
return x - x1.x;
}
Or, pass on to the int compareTo, if you want.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
i think i described my problem wrong
i want to sort the list with either x or y not with both of them
say
object1 x = 5, y = 10
object2 x = 3, y = 7
object3 x = 7, y = 4
Test.Sort() //for x
output
object2
object1
object3
or
Test.Sort() //for y
output
object3
object2
object1
i hope u got wat i mean
thanks
|
|
|
|
|
yosif4444 wrote: i want to sort the list with either x or y not with both of them
So what part of "do whatever you like" don't you understand?
Christian Graus wrote: Your compare to can do whatever you like
led mike
|
|
|
|
|
I know that i can "do whatever i want" but only in one compare function
i want to write many compare functions depending on the variable i want
|
|
|
|
|
OK - I get it.
Create an enum for the different sort orders, then use an instance of that to decide what to do in the compare function.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yeah you got my point
but can u plz help me with code example, coz i don't know how to implement wat u said
thanks in advance
|
|
|
|
|
OK, it's pretty simple
public class SamplesArrayList
{
public class Test : IComparable
{
public enum SortBy { SortByX, SortByY };
private SortBy _sortOrder;
public SortBy
{
get { return _sortOrder; }
set { _sortOrder = value; }
}
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public Test(int x)
{
this.x = x;
}
int IComparable.CompareTo(object x)
{
Test x1 = (Test)x;
switch(SortOrder)
{
int result;
case SortBy.SortByX:
result = (this.x.CompareTo(x1.x));
break;
case SortBy.SortByY:
result = (this.y.CompareTo(x1.y));
break;
default:
throw new ArgumentException("The SortBy enum has been added to, but the CompareTo method has not been updated");
break;
}
return result;
}
}
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Try it ---
using System;
using System.Collections;
using System.Collections.Generic;
public class SamplesArrayList
{
static char indi;
public class Test : IComparable
{
public int x;
public int y;
//this is the variable which i want to sort the list with it also
public char indi;
public Test(int x, int y)
{
this.x = x;
this.y = y;
}
int IComparable.CompareTo(object x)
{
if (indi == 'X')
{
Test x1 = (Test)x;
return (this.x.CompareTo(x1.x));
}
else
{
Test y1 = (Test)x;
return (this.y.CompareTo(y1.y));
}
}
}
public static void Main()
{
ArrayList test = new ArrayList();
Test l1 = new Test(7,8);
Test l2 = new Test(3,2);
Test l3 = new Test(9,1);
Test l4 = new Test(2,0);
Test l5 = new Test(4,5);
indi = 'X';
test.Add(l1);
test.Add(l2);
test.Add(l3);
test.Add(l4);
test.Add(l5);
test.Sort();
foreach (Test t in test)
{
Test x1 = t;
Console.WriteLine(x1.x+ " "+ x1.y);
}
Console.ReadKey();
}
}
|
|
|
|
|
using a char is obviously nasty as hell, but this is the general idea, yes.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Dear FRiends,
We have Imported a DLL in c# which made in VC++.While calling the function of imported dll ,named
void Testing_Function(
ref coordpt[,] polygons, ref int[] polygons_vertex_num, ref double[] polygons_rotation_angle, ref int []polygons_flip, ref
double []polygons_rotation_tolerance, ref int []polygons_placement_group, int polygons_num, double surface_width, double
surface_pattern, double x_rapport, double y_rapport, double x_rapport_offset, double y_rapport_offset, int layer_type, int
layer_type_length_option, ref coordpt[,] holes, ref int[] holes_vertex_num, int holes_num, int product_type, int
number_of_product_pieces, int marker_combi_type, double allowed_time, double termination_yield, ref int manual_interrupt,
ref int intermediate_solution, ref int error_message,ref Nesting_Constraint_Type[]constraints, int constraints_number, ref
int[] polygon_placed, ref double[] x_translation, ref double[] y_translation, ref double[] rotation, ref int[] flip, ref
double[] marker_length1, ref double[] marker_length2, ref double[] marker_yield, int dump
);
in c#.
it is giving Exception as
AccessViolationException was Handled
---------------------------------------
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
plz help me out for this problem asap.
|
|
|
|
|
That's one awful function. Have you considered creating a struct or two, to limit the parameter list ?
The C++ dll has some sort of memory management problem, but how can we know what it is, without seeing the code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
DLL Function in VC++
This is actullay contained 38 parameters.
void Testing_Function
(
coordpt **polygons, /*polygon shapes*/
int *polygons_vertex_num, /*polygon vertex numbers*/
double *polygons_rotation_angle , /*polygon rotation angles*/
int *polygons_flip, /*polygon flip information*/
double *polygons_rotation_tolerance, /*polygon rotation tolerances*/
int *polygons_placement_group, /*polygon placement groups
int polygons_num, /*number of polygons*/
double surface_width, /*width of the surface*/
double surface_pattern, /*pattern on the surface*/
double x_rapport, /*pattern repeat in x-direction*/
double y_rapport, /*pattern repeat in y-direction*/
double x_rapport_offset, /*offset of first plaid line*/
double y_rapport_offset, /*offset of first stripe line*/
int layer_type, /*layer type*/
int layer_type_length_option, /*option for length measuring*/
coordpt **holes, /*holes in the surface*/
int *holes_vertex_num, /*vertex numbers of the holes*/
int holes_num, /*number of holes in the surface*/
int product_type, /*type of product*/
int number_of_product_pieces, /*number of products*/
int marker_combi_type, /*type of stencil combination*/
double allowed_time, /*allowed processing time*/
double termination_yield, /*termination yield*/
int (*manual_interrupt)(), /*manual interrupt*/
int (*intermediate_solution)(), /*output of intermediate solutions*/
int (*error_message)(), /*output of error messages*/
nesting_constraint_type *constraints, /*placement constraints*/
int constraints_number, /*number of constraints*/
int *polygon_placed, /*return: polygon placed or not*/
double *x_translation, /*return: x-translations*/
double *y_translation, /*return: y-translations*/
double *rotation, /*return: rotations*/
int *flip, /*return: flip information*/
double *marker_length1, /*return: front marker length*/
double *marker_length2, /*return: back marker length*/
double *marker_yield, /*return: yield of the marker*/
int dump /*dump option*/
)
but from c# , we are importing this dll function as below
[DllImport("Test-T.dll", EntryPoint = "Test_Function", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
void Testing_Function(
ref coordpt[,] polygons,
ref int[] polygons_vertex_num,
ref double[] polygons_rotation_angle,
ref int []polygons_flip,
ref double []polygons_rotation_tolerance,
ref int []polygons_placement_group,
int polygons_num,
double surface_width,
double surface_pattern,
double x_rapport,
double y_rapport,
double x_rapport_offset,
double y_rapport_offset,
int layer_type,
int layer_type_length_option,
ref coordpt[,] holes, ref int[] holes_vertex_num,
int holes_num,
int product_type,
int number_of_product_pieces,
int marker_combi_type,
double allowed_time, double termination_yield,
ref int manual_interrupt,
ref int intermediate_solution,
ref int error_message,
ref Nesting_Constraint_Type[]constraints, int constraints_number,
ref int[] polygon_placed,
ref double[] x_translation,
ref double[] y_translation,
ref double[] rotation,
ref int[] flip,
ref double[] marker_length1,
ref double[] marker_length2,
ref double[] marker_yield,
int dump
);
and we calculated every parameter from c# and called the Testing_Function.
At called function (Testing_Function ),it is giving error as
AccessViolationException was Handled
---------------------------------------
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
plz help me out for this problem.
|
|
|
|
|