![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Issue with get-content When I use get-content with the binary flag like $bytes=get-content $path -encoding byte Some of the JPEGS I am trying to open cause PowerShell to start eating memory I am opening a 1.5MB image and in the Task Manager it shows PowerShell going from about 10,000k to almost 1.5GB memory usage. I have seen this with multiple JPEGS. It can take a minute or 2 to open one of these files in binary mode, while opening them without the binary flag, they open up in 2 seconds. Any one have any ideas? I am writing scripts to upload 1.5 Million docs into a SharePoint site and this everything appears to be working except for this. Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Issue with get-content "mdifranco" <mdifranco@discussions.microsoft.com> wrote in message news:BB7DA2A3-DEC0-45DF-B580-447D6215E7D7@microsoft.com... > When I use get-content with the binary flag like > > $bytes=get-content $path -encoding byte > > Some of the JPEGS I am trying to open cause PowerShell to start eating > memory > I am opening a 1.5MB image and in the Task Manager it shows PowerShell > going > from about 10,000k to almost 1.5GB memory usage. I have seen this with > multiple JPEGS. It can take a minute or 2 to open one of these files in > binary mode, while opening them without the binary flag, they open up in 2 > seconds. > > Any one have any ideas? I am writing scripts to upload 1.5 Million docs > into a SharePoint site and this everything appears to be working except > for > this. I think it is safe to say that this an area that needs some serious optimization. For now I would just bypass get-content and use this .NET method. It is quite fast: $bytes = [System.IO.File]::ReadAllBytes('C:\Users\Keith\Pictures\Foo.JPG') -- Keith |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Issue with get-content "Keith Hill [MVP]" wrote: > > "mdifranco" <mdifranco@discussions.microsoft.com> wrote in message > news:BB7DA2A3-DEC0-45DF-B580-447D6215E7D7@microsoft.com... > > When I use get-content with the binary flag like > > > > $bytes=get-content $path -encoding byte > > > > Some of the JPEGS I am trying to open cause PowerShell to start eating > > memory > > I am opening a 1.5MB image and in the Task Manager it shows PowerShell > > going > > from about 10,000k to almost 1.5GB memory usage. I have seen this with > > multiple JPEGS. It can take a minute or 2 to open one of these files in > > binary mode, while opening them without the binary flag, they open up in 2 > > seconds. > > > > Any one have any ideas? I am writing scripts to upload 1.5 Million docs > > into a SharePoint site and this everything appears to be working except > > for > > this. > > I think it is safe to say that this an area that needs some serious > optimization. For now I would just bypass get-content and use this .NET > method. It is quite fast: > > $bytes = [System.IO.File]::ReadAllBytes('C:\Users\Keith\Pictures\Foo.JPG') > > -- > Keith > Thanks Keith, I ended up using the .Net classes all ready. $fs = new-object System.IO.FileStream($path,[System.IO.FileMode]::Open, [System.IO.FileAccess]::Read) $fs.open $br = new-object System.IO.BinaryReader($fs) $bytes=[byte[]] $br.ReadBytes($fs.Length) Looks like you code is a little simpler. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |