tags:

views:

212

answers:

4

Hi,

I wrote a WCF service that returns a string[][][][][] (necessary for legacy reasons).

Then I noticed an important fact: if the service manipulates N objects the answer is returned immediately (in localhost) but if it tries to manipulate N+1 objects a timeout occurs (I set it to 30sec).

The problem occurs if the string[20][20][20][5][20] becomes a string[20][20][20][6][20].

Why it takes so much if I add 1 object? The code of the service is not useful so I'll not include it.

Thanks,

Alberto

+2  A: 

Define adding of one object. Give us some source code. Adding item to array, means changing its size and moving items around, which in your case can be very expensive - you have a 5 dimensional array! Why is that?

Update:

I would guess that the original array has less strings in it and more nulls, where the second one where your bottleneck is have more strings.

Ivan Zlatanov
the 5 dimensional string array is necessary for legacy reasons.The problem occurs if the string[20][20][20][5][20] becomes a string[20][20][20][6][20]. The code isn't relevant because the time executing the code is NOT significant, the bottleneck in in the serialization or trasmission. The "strange" thing is the incredible increase of the time from 1 sec to more then 30!Thanks
Alberto
Correct me if I'm wrong, but that's an increase of 160,000 not an increase of 1.
David M
Well the [20][20][20][5][20] means = 800 000 Strings! Enormous. If you only add 1 to the 5, then it becomes 960 000 Strings - 160 000 more just by increasing 1 integer. Though I would suggest checking your string initialization - I would guess that the original array has less strings in it and more nulls, where the second one where your bottleneck is have more strings.
Ivan Zlatanov
TO DAVID M: Yes the increase in the output is 160k when I add 1 object to manipulate. We both right...TO IVAN: Thanks. I'll clean up the null arrays to have a minor impact. Can you please edit your original answer with the part in the comment so I can give you a vote up?Thanks!
Alberto
I have updated my original post.
Ivan Zlatanov
And I gave you rep! Thanks!Thanks also to David, I can only vote up comment!
Alberto
+1  A: 

IMHO, if you are using a string[][][][][], there is something wrong in your design.

HyLian
the 5 dimensional string array is necessary for legacy reasons...
Alberto
Even "back in the day", a five-dimensional array of strings was, at best, a questionable design, and most likely just plain dumb.
John Saunders
+1  A: 

check to see if the datacontract seriializer is set to max objects in graph.sometimes the default which is set to a low value can cause this to happen. We had a similar problem when 1000 things returned from WCF to populate a dropdown failed just becaise of this.

<behaviors>
    <behavior name="CalculatorServiceBehavior">
        <dataContractSerializer maxItemsInObjectGraph="6553600" />
    </behavior>
</behaviors>

view link

chugh97
Thanks, it isn't the solution of my problem but it could be an answer for others so I'll vote up.
Alberto
A: 

The problem was the maxReceivedMessageSize, a parameter that indicates the higher amount of message exchanged.

Setting it to 6291456 the service worked well.

Alberto

Alberto