Re: out of memory..urgent...Solution

2013-09-13 Thread Greg Keogh
>
> UTF8 is a variable-width encoding so if the buffer is >100kB and a valid
> multi-byte UTF8 encoded character happens to fall across the boundary of
> buffers in subsequent loop iterations you might get either an incorrect
> decoding or an exception thrown.
>

Right, decoding the bytes in fixed blocks with GetString is very fragile.
If you want to make a string out of unpredictable chunks of bytes (as they
would come out of a network stream for example) you need to use this:

http://msdn.microsoft.com/en-us/library/system.text.encoding.getencoder.aspx

This is just a side issue to your original post.

Greg K


RE: out of memory..urgent...Solution

2013-09-13 Thread David Kean
Yes, Tony is right.

You're also haven't really solved the memory issue - you still have two copies 
of the data.

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of Tony McGee
Sent: Friday, September 13, 2013 5:43 AM
To: ozDotNet
Subject: Re: out of memory..urgent...Solution

Does that code have a nasty edge case bug?
UTF8 is a variable-width encoding so if the buffer is >100kB and a valid 
multi-byte UTF8 encoded character happens to fall across the boundary of 
buffers in subsequent loop iterations you might get either an incorrect 
decoding or an exception thrown.


On 13/09/2013 14:46, 
anthonyatsmall...@mail.com wrote:
If you are interested..memeory issue was resolved by doing the following...


  Public Shared Function byteArrayToString(ByVal b() As Byte) As String
Dim ss As New System.Text.UTF8Encoding
Dim sString As String
Dim sb As New StringBuilder
Dim cursor As Integer
Dim sChunk As String
Try



' sString = System.Text.Encoding.UTF8.GetString(b)

While cursor < b.Length

Dim arr2() As Byte

If (cursor + 10) > (b.Length) Then
arr2 = New Byte(b.Length - cursor - 1) {}
Array.Copy(b, cursor, arr2, 0, b.Length - cursor)
Else
arr2 = New Byte(10 - 1) {}
Array.Copy(b, cursor, arr2, 0, 10)
End If


sChunk = System.Text.Encoding.UTF8.GetString(arr2)
sb.Append(sChunk)
cursor += 10

End While

' sString = ss.GetString(b)
Return sb.ToString
Catch ex As Exception
Throw ex
End Try

End Function



Anthony
Melbourne StuffUps...learn from others, share with others!
http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/

--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the addressee. If 
you are not the intended recipient, you are hereby notified that any 
disclosure, reproduction, distribution or other use of this communication is 
strictly prohibited.
If you have received this communication in error, please notify the sender by 
reply transmission and delete the message without copying or disclosing it. 
(*13POrtC*)
---

From: ozdotnet-boun...@ozdotnet.com 
[mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of David Kean
Sent: Wednesday, 11 September 2013 2:20 AM
To: ozDotNet
Subject: RE: out of memory..urgent

Memory isn't unlimited. Basically, when you convert from a byte array -> 
string, you have two copies of the same data (one for the byte array and one 
for the string) in memory.

What exactly are you doing? You are typically better off chunking and reading 
smaller amounts of data at a time. Use something like a StreamWriter over a 
stream to automatically handles the byte -> text conversion.

From: ozdotnet-boun...@ozdotnet.com 
[mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of 
anthonyatsmall...@mail.com
Sent: Monday, September 9, 2013 8:05 PM
To: ozDotNet
Subject: out of memory..urgent

Getting out of memory exception when I try to

Dim s as string
Dim b() as Byte

s=System.Text.Encoding.GetEncoding("utf-8).GetString(b)

Definitely something about the length of b..works fine most of the time except 
if b length is very large

Anthony
Melbourne StuffUps...learn from others, share with others!
http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/

--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the addressee. If 
you are not the intended recipient, you are hereby notified that any 
disclosure, reproduction, distribution or other use of this communication is 
strictly prohibited.
If you have received this communication in error, please notify the sender by 
reply transmission and delete the message without copying or disclosing it. 
(*13POrtC*)
---




Re: out of memory..urgent...Solution

2013-09-13 Thread Tony McGee

Does that code have a nasty edge case bug?
UTF8 is a variable-width encoding so if the buffer is >100kB and a valid 
multi-byte UTF8 encoded character happens to fall across the boundary of 
buffers in subsequent loop iterations you might get either an incorrect 
decoding or an exception thrown.



On 13/09/2013 14:46, anthonyatsmall...@mail.com wrote:


If you are interested..memeory issue was resolved by doing the 
following...


Public Shared Function byteArrayToString(ByVal b() As Byte) As String

Dim ss As New System.Text.UTF8Encoding

Dim sString As String

Dim sb As New StringBuilder

Dim cursor As Integer

Dim sChunk As String

Try

' sString = System.Text.Encoding.UTF8.GetString(b)

While cursor < b.Length

Dim arr2() As Byte

If (cursor + 10) > (b.Length) Then

arr2 = New Byte(b.Length - cursor - 1) {}

Array.Copy(b, cursor, arr2, 0, b.Length - cursor)

Else

arr2 = New Byte(10 - 1) {}

Array.Copy(b, cursor, arr2, 0, 10)

End If

sChunk = System.Text.Encoding.UTF8.GetString(arr2)

sb.Append(sChunk)

cursor += 10

End While

' sString = ss.GetString(b)

Return sb.ToString

Catch ex As Exception

Throw ex

End Try

End Function

Anthony

Melbourne StuffUps...learn from others, share with others!

http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/


--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the 
addressee. If you are not the intended recipient, you are hereby 
notified that any disclosure, reproduction, distribution or other use 
of this communication is strictly prohibited.
If you have received this communication in error, please notify the 
sender by reply transmission and delete the message without copying or 
disclosing it. (*13POrtC*)

---

*From:*ozdotnet-boun...@ozdotnet.com 
[mailto:ozdotnet-boun...@ozdotnet.com] *On Behalf Of *David Kean

*Sent:* Wednesday, 11 September 2013 2:20 AM
*To:* ozDotNet
*Subject:* RE: out of memory..urgent

Memory isn't unlimited. Basically, when you convert from a byte array 
-> string, you have two copies of the same data (one for the byte 
array and one for the string) in memory.


What exactly are you doing? You are typically better off chunking and 
reading smaller amounts of data at a time. Use something like a 
StreamWriter over a stream to automatically handles the byte -> text 
conversion.


*From:*ozdotnet-boun...@ozdotnet.com 
[mailto:ozdotnet-boun...@ozdotnet.com] *On Behalf Of 
*anthonyatsmall...@mail.com

*Sent:* Monday, September 9, 2013 8:05 PM
*To:* ozDotNet
*Subject:* out of memory..urgent

Getting out of memory exception when I try to

Dim s as string

Dim b() as Byte

s=System.Text.Encoding.GetEncoding("utf-8).GetString(b)

Definitely something about the length of b..works fine most of the 
time except if b length is very large


Anthony

Melbourne StuffUps...learn from others, share with others!

http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/


--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the 
addressee. If you are not the intended recipient, you are hereby 
notified that any disclosure, reproduction, distribution or other use 
of this communication is strictly prohibited.
If you have received this communication in error, please notify the 
sender by reply transmission and delete the message without copying or 
disclosing it. (*13POrtC*)

---





Expression Web

2013-09-13 Thread Greg Keogh
Folks, several weeks ago I discovered I accidentally didn't install
Expression Blend with VS2012 because I thought it was the same as V4 and
would be duplicating effort. After correcting this misunderstanding and
reading more about what's happening with the Expression Suite I'm becoming
rather bewildered. See official page
HERE
.

*Blend* is now merging (sort of) with VS2012. *Encoder* will be absorbed by
Azure Media Services. The future of *Design* is completely indecipherable
from the wording on the site. *Web* is apparently being replaced by VS2012,
and that's the bit that really surprised me. This is one hell of a shakeup.

I used FrontPage for a few years after it came out, then I used Dreamweaver
for several years, then I moved to Expression Web (and discovered it was
FrontPage sneakily renamed) and I'm using that now for mostly traditional
static web site authoring. Now I'm told that it will be replaced by VS2012
... well, whoopee because that's a product I'm familiar with, but I never
considered it a candidate for managing "web sites". The old products were
custom made for the job, maintaining databases of "sites", cross references
of links and publishing options, but VS2012 doesn't seem built for that
purpose.

Can anyone confirm that VS2012 is a viable and capable product for creating
large web sites full of mostly traditional static pages? Perhaps it can do
that as a subset of some larger feature set I've ignored.

Greg K


RE: out of memory..urgent...Solution

2013-09-13 Thread anthonyatsmallbiz
Thanks Mike..will implement your advice..just being lazy

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of mike smith
Sent: Friday, 13 September 2013 5:13 PM
To: ozDotNet
Subject: Re: out of memory..urgent...Solution

 

Like this.

 

http://msdn.microsoft.com/en-us/library/ee787088.aspx#generations

 

Your inner loop variable arr2 is going to get GC because it falls out of scope 
every time it loops.  The vars declared outside are not.  I was wondering if 
you were doing that deliberately, instead of making it a fixed size outside the 
loop and say clearing it inside rather than re-allocating every time.

 

Mike

 

On Fri, Sep 13, 2013 at 4:55 PM,  wrote:

What do you mean?  

 

Anthony

Melbourne StuffUps…learn from others, share with others!

http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/


--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the addressee. If 
you are not the intended recipient, you are hereby notified that any 
disclosure, reproduction, distribution or other use of this communication is 
strictly prohibited. 
If you have received this communication in error, please notify the sender by 
reply transmission and delete the message without copying or disclosing it. 
(*13POrtC*)
---
 

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of mike smith
Sent: Friday, 13 September 2013 4:50 PM
To: ozDotNet
Subject: Re: out of memory..urgent...Solution

 

Are you doing something odd with generational garbage collection here?  

 

On Fri, Sep 13, 2013 at 2:46 PM,  wrote:

If you are interested..memeory issue was resolved by doing the following…

 

 

  Public Shared Function byteArrayToString(ByVal b() As Byte) As String

Dim ss As New System.Text.UTF8Encoding

Dim sString As String

Dim sb As New StringBuilder

Dim cursor As Integer

Dim sChunk As String

Try

 

 

 

' sString = System.Text.Encoding.UTF8.GetString(b)

 

While cursor < b.Length

 

Dim arr2() As Byte

 

If (cursor + 10) > (b.Length) Then

arr2 = New Byte(b.Length - cursor - 1) {}

Array.Copy(b, cursor, arr2, 0, b.Length - cursor)

Else

arr2 = New Byte(10 - 1) {}

Array.Copy(b, cursor, arr2, 0, 10)

End If

 

 

sChunk = System.Text.Encoding.UTF8.GetString(arr2)

sb.Append(sChunk)

cursor += 10

 

End While

 

' sString = ss.GetString(b)

Return sb.ToString

Catch ex As Exception

Throw ex

End Try

 

End Function

 

 

 

Anthony

Melbourne StuffUps…learn from others, share with others!

http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/


--
NOTICE : The information contained in this electronic mail message is 
privileged and confidential, and is intended only for use of the addressee. If 
you are not the intended recipient, you are hereby notified that any 
disclosure, reproduction, distribution or other use of this communication is 
strictly prohibited. 
If you have received this communication in error, please notify the sender by 
reply transmission and delete the message without copying or disclosing it. 
(*13POrtC*)
---
 

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of David Kean
Sent: Wednesday, 11 September 2013 2:20 AM
To: ozDotNet
Subject: RE: out of memory..urgent

 

Memory isn’t unlimited. Basically, when you convert from a byte array -> 
string, you have two copies of the same data (one for the byte array and one 
for the string) in memory.

 

What exactly are you doing? You are typically better off chunking and reading 
smaller amounts of data at a time. Use something like a StreamWriter over a 
stream to automatically handles the byte -> text conversion.

 

From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On 
Behalf Of anthonyatsmall...@mail.com
Sent: Monday, September 9, 2013 8:05 PM
To: ozDotNet
Subject: out of memory..urgent

 

Getting out of memory exception when I try to

 

Dim s as string

Dim b() as Byte

 

s=System.Text.Encoding.GetEncoding(“utf-8).GetString(b) 

 

Definitely something about the length of b..works fine most of the time except 
if b length is very large

 

Anthony

Melbourne StuffUps…learn from others, share with others!

http://www

RE: out of memory..urgent...Solution

2013-09-13 Thread anthonyatsmallbiz
I agree with what your saying but other people have had this issue...it
worked for me and haven't worried about it. 

-Original Message-
From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
On Behalf Of Mark Hurd
Sent: Friday, 13 September 2013 6:20 PM
To: ozDotNet
Subject: Re: out of memory..urgent...Solution

I am surprised this solves your memory problem, as although the UTF8
GetString(Byte[]) defers to Encoding's base method, that returns the result
of GetString(Byte[], int, int) which is overridden by UTF8, which calls
String.CreateStringFromEncoding.

This uses String.FastAllocateString to create the string of size based upon
UTF8's override of GetCharCount, which I haven't reviewed closely, but it
doesn't look like it's an estimate :-)

The String's internal Char[] is manipulated directly by UTF8's internal
GetChars, so unless GetCharCount does get it vastly wrong, I don't see how
your "fix", which starts with a 16 byte StringBuilder buffer that will be
increased by the 10 chars each time you Append, with the existing
content copied across each time.

In summary, in your last loop iteration there will need to be almost twice
your whole string required in memory for a short time as the last chunk is
Appended.

Whereas as far as I see in the (Reflected) code, the simple GetString should
just hold the whole String once and work within it.

So if your fix really is a fix, I suggest there's a bug in UTF8's
GetCharCount (or I'm wrong and it /is/ just estimating how many Chars are
needed).

--
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

On 13 September 2013 14:16,   wrote:
> If you are interested..memeory issue was resolved by doing the 
> following.
>
>
>
>
>
>   Public Shared Function byteArrayToString(ByVal b() As Byte) As 
> String
>
> Dim ss As New System.Text.UTF8Encoding
>
> Dim sString As String
>
> Dim sb As New StringBuilder
>
> Dim cursor As Integer
>
> Dim sChunk As String
>
> Try
>
>
>
>
>
>
>
> ' sString = System.Text.Encoding.UTF8.GetString(b)
>
>
>
> While cursor < b.Length
>
>
>
> Dim arr2() As Byte
>
>
>
> If (cursor + 10) > (b.Length) Then
>
> arr2 = New Byte(b.Length - cursor - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, b.Length - cursor)
>
> Else
>
> arr2 = New Byte(10 - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, 10)
>
> End If
>
>
>
>
>
> sChunk = System.Text.Encoding.UTF8.GetString(arr2)
>
> sb.Append(sChunk)
>
> cursor += 10
>
>
>
> End While
>
>
>
> ' sString = ss.GetString(b)
>
> Return sb.ToString
>
> Catch ex As Exception
>
> Throw ex
>
> End Try
>
>
>
> End Function
>
>
>
>
>
>
>
> Anthony
>
> Melbourne StuffUps.learn from others, share with others!
>
> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startu
> ps/
>
>
> --
>  NOTICE : The information contained in this electronic 
> mail message is privileged and confidential, and is intended only for 
> use of the addressee.
> If you are not the intended recipient, you are hereby notified that 
> any disclosure, reproduction, distribution or other use of this 
> communication is strictly prohibited.
> If you have received this communication in error, please notify the 
> sender by reply transmission and delete the message without copying or 
> disclosing it. (*13POrtC*)
> --
> -
>
>
>
> From: ozdotnet-boun...@ozdotnet.com 
> [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of David Kean
> Sent: Wednesday, 11 September 2013 2:20 AM
> To: ozDotNet
> Subject: RE: out of memory..urgent
>
>
>
> Memory isn't unlimited. Basically, when you convert from a byte array 
> -> string, you have two copies of the same data (one for the byte 
> array and one for the string) in memory.
>
>
>
> What exactly are you doing? You are typically better off chunking and 
> reading smaller amounts of data at a time. Use something like a 
> StreamWriter over a stream to automatically handles the byte -> text
conversion.
>
>
>
> From: ozdotnet-boun...@ozdotnet.com 
> [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of anthonyatsmall...@mail.com
> Sent: Monday, September 9, 2013 8:05 PM
> To: ozDotNet
> Subject: out of memory..urgent
>
>
>
> Getting out of memory exception when I try to
>
>
>
> Dim s as string
>
> Dim b() as Byte
>
>
>
> s=System.Text.Encoding.GetEncoding("utf-8).GetString(b)
>
>
>
> Definitely something about the length of b..works fine most of the 
> time except if b length is very large
>
>
>
> Anthony
>
> Melbourne StuffUps.learn from others, share with others!
>
> http://www.meetup.com/Melbour

Re: Code commenting

2013-09-13 Thread David Rhys Jones
For the last 5 years or so the only comments that I have left in code. are
the public interface XML comments that are well written with examples. not
the usual you find.
/// 
/// Gets the User by Id
/// 
public void GetUserById(long id){}

I have left comments that point out that a bug exists in something we can't
control.
like a "Log.Debug" in a tight loop that I've put "if log.IsDebug" around
for performance reasons.

a couple of years ago, we were working on a project that was full stylecop
and code analysis doing it by TDD.  When the company changed it's
acceptance rules to be more strict, we were 90% compliant. However they
complained that there were only 12 comments in the entire solution.

if you have to make comments in the code, always prefix it with something
that is constant so the task list picks it up.  The HACK, TODO and UNDONE
are adequate, I've found that customizing this list is counter productive
because you miss the other developers tags if they add them without consent
of the team.

2c
Davy

Davy,

The US Congress voted Pizza sauce a vegetable. Don't even try to convince
me of anything in the states is sane any more!


On Fri, Sep 13, 2013 at 10:38 AM, Sam Lai  wrote:

> No comments at all is a bit extreme. I get what you're saying, but there
> are still valid reasons for comments. For example, if you had to do an
> unusual hack because of a bug in the framework, you'd want to leave a
> comment in the code so the next person who comes along doesn't spend hours
> re-writing it so it is done properly only to realise after that a bug
> exists.
>
> Do docstrings/javadocs count as comments?
>
> I agree about no 'person x made this change on y because of issue z'
> comments though; if your source control doesn't make that easy to
> determine, then get a new source control system.
>
>
> On 13 September 2013 17:56, Davy Jones  wrote:
>
>> Hello
>> If you are doing this in code. It points to the fact that someone is not
>> pulling their weight.
>> Code should not have comments. If you need them to explain something, the
>> code is too complex.
>> If you add them so modifications on one bit of code come back to you so
>> you can fix. Make it simpler.
>> If you add them to Blame later, you should be doing peer reviewed
>> checkins to bring everyone up to the same level.
>> If you are commenting code because it might be useful later. Delete it!
>> That is what source control is for.
>>
>> There is no excuse for comments in code.
>>
>> Davy
>>
>> Sent from my starfleet datapad.
>>
>> On 13 sept. 2013, at 08:56, mike smith  wrote:
>>
>> Blame is a useful tool, ofttimes though, I'd call it credit.  For
>> instance, you receive a crashdump from an old version, it shows you where
>> the app crashed, and maybe you have a slight idea why.  Use blame on a
>> current version, look at changes around the crash line and you've got a lot
>> of the info you might need to generate a hotfix.  With all the caveats that
>> hotfixes imply :)  If your devs are diligent linking the svn comment with a
>> number from your CR system, that's another link.
>>
>> But I'd hate to see it actually present in the code.
>>
>>
>>
>>
>> On Fri, Sep 13, 2013 at 2:50 PM, Craig van Nieuwkerk 
>> wrote:
>>
>>> A lot of source control systems give you that out of the box. I know Git
>>> and SVN both do with the BLAME command. I wouldn't want the comments
>>> scattered throughout the code.
>>>
>>>
>>> On Fri, Sep 13, 2013 at 2:45 PM,  wrote:
>>>
 Anyone suggest a method to autmaticlly comment code when lines have
 changed?  Would be great to be able to see who changed what when viewing
 the code.

 ** **

 At the moment,, we write comments like //xxMOD 12AUG13   XX=PROGRAMMER
 INITIALS

 ** **

 WE use TFS but we like to write comments in code sometimes.  Any
 extensions able to do this?

 ** **

 Anthony

 Melbourne StuffUps…learn from others, share with others!


 http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/
 



 --
 NOTICE : The information contained in this electronic mail message is
 privileged and confidential, and is intended only for use of the addressee.
 If you are not the intended recipient, you are hereby notified that any
 disclosure, reproduction, distribution or other use of this communication
 is strictly prohibited.
 If you have received this communication in error, please notify the
 sender by reply transmission and delete the message without copying or
 disclosing it. (*13POrtC*)

 ---
 

 ** **

>>>
>>>
>>
>>
>> --
>> Meski
>>
>>http://courteous.ly/aAOZcv
>>
>> "Going to Starbucks for coffee is like going to prison for sex. Sure,
>> you'll

Re: Code commenting

2013-09-13 Thread Sam Lai
No comments at all is a bit extreme. I get what you're saying, but there
are still valid reasons for comments. For example, if you had to do an
unusual hack because of a bug in the framework, you'd want to leave a
comment in the code so the next person who comes along doesn't spend hours
re-writing it so it is done properly only to realise after that a bug
exists.

Do docstrings/javadocs count as comments?

I agree about no 'person x made this change on y because of issue z'
comments though; if your source control doesn't make that easy to
determine, then get a new source control system.


On 13 September 2013 17:56, Davy Jones  wrote:

> Hello
> If you are doing this in code. It points to the fact that someone is not
> pulling their weight.
> Code should not have comments. If you need them to explain something, the
> code is too complex.
> If you add them so modifications on one bit of code come back to you so
> you can fix. Make it simpler.
> If you add them to Blame later, you should be doing peer reviewed checkins
> to bring everyone up to the same level.
> If you are commenting code because it might be useful later. Delete it!
> That is what source control is for.
>
> There is no excuse for comments in code.
>
> Davy
>
> Sent from my starfleet datapad.
>
> On 13 sept. 2013, at 08:56, mike smith  wrote:
>
> Blame is a useful tool, ofttimes though, I'd call it credit.  For
> instance, you receive a crashdump from an old version, it shows you where
> the app crashed, and maybe you have a slight idea why.  Use blame on a
> current version, look at changes around the crash line and you've got a lot
> of the info you might need to generate a hotfix.  With all the caveats that
> hotfixes imply :)  If your devs are diligent linking the svn comment with a
> number from your CR system, that's another link.
>
> But I'd hate to see it actually present in the code.
>
>
>
>
> On Fri, Sep 13, 2013 at 2:50 PM, Craig van Nieuwkerk wrote:
>
>> A lot of source control systems give you that out of the box. I know Git
>> and SVN both do with the BLAME command. I wouldn't want the comments
>> scattered throughout the code.
>>
>>
>> On Fri, Sep 13, 2013 at 2:45 PM,  wrote:
>>
>>> Anyone suggest a method to autmaticlly comment code when lines have
>>> changed?  Would be great to be able to see who changed what when viewing
>>> the code.
>>>
>>> ** **
>>>
>>> At the moment,, we write comments like //xxMOD 12AUG13   XX=PROGRAMMER
>>> INITIALS
>>>
>>> ** **
>>>
>>> WE use TFS but we like to write comments in code sometimes.  Any
>>> extensions able to do this?
>>>
>>> ** **
>>>
>>> Anthony
>>>
>>> Melbourne StuffUps…learn from others, share with others!
>>>
>>> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/
>>> 
>>>
>>>
>>>
>>> --
>>> NOTICE : The information contained in this electronic mail message is
>>> privileged and confidential, and is intended only for use of the addressee.
>>> If you are not the intended recipient, you are hereby notified that any
>>> disclosure, reproduction, distribution or other use of this communication
>>> is strictly prohibited.
>>> If you have received this communication in error, please notify the
>>> sender by reply transmission and delete the message without copying or
>>> disclosing it. (*13POrtC*)
>>>
>>> ---
>>> 
>>>
>>> ** **
>>>
>>
>>
>
>
> --
> Meski
>
>http://courteous.ly/aAOZcv
>
> "Going to Starbucks for coffee is like going to prison for sex. Sure,
> you'll get it, but it's going to be rough" - Adam Hills
>
>


Re: out of memory..urgent...Solution

2013-09-13 Thread Mark Hurd
I am surprised this solves your memory problem, as although the UTF8
GetString(Byte[]) defers to Encoding's base method, that returns the
result of GetString(Byte[], int, int) which is overridden by UTF8,
which calls String.CreateStringFromEncoding.

This uses String.FastAllocateString to create the string of size based
upon UTF8's override of GetCharCount, which I haven't reviewed
closely, but it doesn't look like it's an estimate :-)

The String's internal Char[] is manipulated directly by UTF8's
internal GetChars, so unless GetCharCount does get it vastly wrong, I
don't see how your "fix", which starts with a 16 byte StringBuilder
buffer that will be increased by the 10 chars each time you
Append, with the existing content copied across each time.

In summary, in your last loop iteration there will need to be almost
twice your whole string required in memory for a short time as the
last chunk is Appended.

Whereas as far as I see in the (Reflected) code, the simple GetString
should just hold the whole String once and work within it.

So if your fix really is a fix, I suggest there's a bug in UTF8's
GetCharCount (or I'm wrong and it /is/ just estimating how many Chars
are needed).

-- 
Regards,
Mark Hurd, B.Sc.(Ma.)(Hons.)

On 13 September 2013 14:16,   wrote:
> If you are interested..memeory issue was resolved by doing the following…
>
>
>
>
>
>   Public Shared Function byteArrayToString(ByVal b() As Byte) As String
>
> Dim ss As New System.Text.UTF8Encoding
>
> Dim sString As String
>
> Dim sb As New StringBuilder
>
> Dim cursor As Integer
>
> Dim sChunk As String
>
> Try
>
>
>
>
>
>
>
> ' sString = System.Text.Encoding.UTF8.GetString(b)
>
>
>
> While cursor < b.Length
>
>
>
> Dim arr2() As Byte
>
>
>
> If (cursor + 10) > (b.Length) Then
>
> arr2 = New Byte(b.Length - cursor - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, b.Length - cursor)
>
> Else
>
> arr2 = New Byte(10 - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, 10)
>
> End If
>
>
>
>
>
> sChunk = System.Text.Encoding.UTF8.GetString(arr2)
>
> sb.Append(sChunk)
>
> cursor += 10
>
>
>
> End While
>
>
>
> ' sString = ss.GetString(b)
>
> Return sb.ToString
>
> Catch ex As Exception
>
> Throw ex
>
> End Try
>
>
>
> End Function
>
>
>
>
>
>
>
> Anthony
>
> Melbourne StuffUps…learn from others, share with others!
>
> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/
>
>
> --
> NOTICE : The information contained in this electronic mail message is
> privileged and confidential, and is intended only for use of the addressee.
> If you are not the intended recipient, you are hereby notified that any
> disclosure, reproduction, distribution or other use of this communication is
> strictly prohibited.
> If you have received this communication in error, please notify the sender
> by reply transmission and delete the message without copying or disclosing
> it. (*13POrtC*)
> ---
>
>
>
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of David Kean
> Sent: Wednesday, 11 September 2013 2:20 AM
> To: ozDotNet
> Subject: RE: out of memory..urgent
>
>
>
> Memory isn’t unlimited. Basically, when you convert from a byte array ->
> string, you have two copies of the same data (one for the byte array and one
> for the string) in memory.
>
>
>
> What exactly are you doing? You are typically better off chunking and
> reading smaller amounts of data at a time. Use something like a StreamWriter
> over a stream to automatically handles the byte -> text conversion.
>
>
>
> From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com]
> On Behalf Of anthonyatsmall...@mail.com
> Sent: Monday, September 9, 2013 8:05 PM
> To: ozDotNet
> Subject: out of memory..urgent
>
>
>
> Getting out of memory exception when I try to
>
>
>
> Dim s as string
>
> Dim b() as Byte
>
>
>
> s=System.Text.Encoding.GetEncoding(“utf-8).GetString(b)
>
>
>
> Definitely something about the length of b..works fine most of the time
> except if b length is very large
>
>
>
> Anthony
>
> Melbourne StuffUps…learn from others, share with others!
>
> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/
>
>
> --
> NOTICE : The information contained in this electronic mail message is
> privileged and confidential, and is intended only for use of the addressee.
> If you are not the intended recipient, you are hereby notified that any
> disclosure, re

Re: Code commenting

2013-09-13 Thread Davy Jones
Hello
If you are doing this in code. It points to the fact that someone is not
pulling their weight.
Code should not have comments. If you need them to explain something, the
code is too complex.
If you add them so modifications on one bit of code come back to you so you
can fix. Make it simpler.
If you add them to Blame later, you should be doing peer reviewed checkins
to bring everyone up to the same level.
If you are commenting code because it might be useful later. Delete it!
That is what source control is for.

There is no excuse for comments in code.

Davy

Sent from my starfleet datapad.

On 13 sept. 2013, at 08:56, mike smith  wrote:

Blame is a useful tool, ofttimes though, I'd call it credit.  For instance,
you receive a crashdump from an old version, it shows you where the app
crashed, and maybe you have a slight idea why.  Use blame on a current
version, look at changes around the crash line and you've got a lot of the
info you might need to generate a hotfix.  With all the caveats that
hotfixes imply :)  If your devs are diligent linking the svn comment with a
number from your CR system, that's another link.

But I'd hate to see it actually present in the code.




On Fri, Sep 13, 2013 at 2:50 PM, Craig van Nieuwkerk wrote:

> A lot of source control systems give you that out of the box. I know Git
> and SVN both do with the BLAME command. I wouldn't want the comments
> scattered throughout the code.
>
>
> On Fri, Sep 13, 2013 at 2:45 PM,  wrote:
>
>> Anyone suggest a method to autmaticlly comment code when lines have
>> changed?  Would be great to be able to see who changed what when viewing
>> the code.
>>
>> ** **
>>
>> At the moment,, we write comments like //xxMOD 12AUG13   XX=PROGRAMMER
>> INITIALS
>>
>> ** **
>>
>> WE use TFS but we like to write comments in code sometimes.  Any
>> extensions able to do this?
>>
>> ** **
>>
>> Anthony
>>
>> Melbourne StuffUps…learn from others, share with others!
>>
>> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/
>> 
>>
>>
>>
>> --
>> NOTICE : The information contained in this electronic mail message is
>> privileged and confidential, and is intended only for use of the addressee.
>> If you are not the intended recipient, you are hereby notified that any
>> disclosure, reproduction, distribution or other use of this communication
>> is strictly prohibited.
>> If you have received this communication in error, please notify the
>> sender by reply transmission and delete the message without copying or
>> disclosing it. (*13POrtC*)
>>
>> ---
>> 
>>
>> ** **
>>
>
>


-- 
Meski

   http://courteous.ly/aAOZcv

"Going to Starbucks for coffee is like going to prison for sex. Sure,
you'll get it, but it's going to be rough" - Adam Hills


Re: out of memory..urgent...Solution

2013-09-13 Thread mike smith
Like this.

http://msdn.microsoft.com/en-us/library/ee787088.aspx#generations

Your inner loop variable arr2 is going to get GC because it falls out of
scope every time it loops.  The vars declared outside are not.  I was
wondering if you were doing that deliberately, instead of making it a fixed
size outside the loop and say clearing it inside rather than re-allocating
every time.

Mike


On Fri, Sep 13, 2013 at 4:55 PM,  wrote:

> What do you mean?  
>
> ** **
>
> Anthony
>
> Melbourne StuffUps…learn from others, share with others!
>
> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/*
> ***
>
>
>
> --
> NOTICE : The information contained in this electronic mail message is
> privileged and confidential, and is intended only for use of the addressee.
> If you are not the intended recipient, you are hereby notified that any
> disclosure, reproduction, distribution or other use of this communication
> is strictly prohibited.
> If you have received this communication in error, please notify the sender
> by reply transmission and delete the message without copying or disclosing
> it. (*13POrtC*)
>
> ---
> 
>
> ** **
>
> *From:* ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *mike smith
> *Sent:* Friday, 13 September 2013 4:50 PM
> *To:* ozDotNet
> *Subject:* Re: out of memory..urgent...Solution
>
> ** **
>
> Are you doing something odd with generational garbage collection here?  **
> **
>
> ** **
>
> On Fri, Sep 13, 2013 at 2:46 PM,  wrote:
>
> If you are interested..memeory issue was resolved by doing the following…*
> ***
>
>  
>
>  
>
>   Public Shared Function byteArrayToString(ByVal b() As Byte) As String***
> *
>
> Dim ss As New System.Text.UTF8Encoding
>
> Dim sString As String
>
> Dim sb As New StringBuilder
>
> Dim cursor As Integer
>
> Dim sChunk As String
>
> Try
>
>  
>
>  
>
>  
>
> ' sString = System.Text.Encoding.UTF8.GetString(b)
>
>  
>
> While cursor < b.Length
>
>  
>
> Dim arr2() As Byte
>
>  
>
> If (cursor + 10) > (b.Length) Then
>
> arr2 = New Byte(b.Length - cursor - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, b.Length - cursor)
>
> Else
>
> arr2 = New Byte(10 - 1) {}
>
> Array.Copy(b, cursor, arr2, 0, 10)
>
> End If
>
>  
>
>  
>
> sChunk = System.Text.Encoding.UTF8.GetString(arr2)
>
> sb.Append(sChunk)
>
> cursor += 10
>
>  
>
> End While
>
>  
>
> ' sString = ss.GetString(b)
>
> Return sb.ToString
>
> Catch ex As Exception
>
> Throw ex
>
> End Try
>
>  
>
> End Function
>
>  
>
>  
>
>  
>
> Anthony
>
> Melbourne StuffUps…learn from others, share with others!
>
> http://www.meetup.com/Melbourne-Ideas-Incubator-Stuffups-Failed-Startups/*
> ***
>
>
>
> --
> NOTICE : The information contained in this electronic mail message is
> privileged and confidential, and is intended only for use of the addressee.
> If you are not the intended recipient, you are hereby notified that any
> disclosure, reproduction, distribution or other use of this communication
> is strictly prohibited.
> If you have received this communication in error, please notify the sender
> by reply transmission and delete the message without copying or disclosing
> it. (*13POrtC*)
>
> ---
> 
>
>  
>
> *From:* ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *David Kean
> *Sent:* Wednesday, 11 September 2013 2:20 AM
> *To:* ozDotNet
> *Subject:* RE: out of memory..urgent
>
>  
>
> Memory isn’t unlimited. Basically, when you convert from a byte array ->
> string, you have two copies of the same data (one for the byte array and
> one for the string) in memory.
>
>  
>
> What exactly are you doing? You are typically better off chunking and
> reading smaller amounts of data at a time. Use something like a
> StreamWriter over a stream to automatically handles the byte -> text
> conversion.
>
>  
>
> *From:* ozdotnet-boun...@ozdotnet.com [mailto:
> ozdotnet-boun...@ozdotnet.com] *On Behalf Of *anthonyatsmall...@mail.com
> *Sent:* Monday, September 9, 2013 8:05 PM
> *To:* ozDotNet
> *Subject:* out of memory..urgent
>
>  
>
> Getting out of memo