![]() |
|
[.NET] [Small challenge] how to fix this error (small gzip source) - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] [Small challenge] how to fix this error (small gzip source) (/showthread.php?tid=5023985) |
[Small challenge] how to fix this error (small gzip source) - DeStilleGast - Oct 16, 2015 Hello HackForums people, For a while I have seen many "Help me" topics and not much "challenges" so I got here a challenge for you guys and also maybe some usefull code Here is a piece of code that gives a "OutOfMemory" error: Button 1 Code Dim openFile As New OpenFileDialogCompress function Code Public Function Compress(ByVal Raw() As Byte) As Byte()Trying to compress a big file (600MB) will result in this: ![]() If done correctly it will result is this: ![]() The ".pak" file is the original file. The ".pak.gz" file is the compressed file. THIS IS NOT A HELP REQUEST, I JUST WANT TO CHALLENGE SOME PEOPLE HERE and also to give a small source for gzip (haven't seen it here yet) If need I can provide a video with the error (with source) and I my solution (without showing the source). Also I WILL release the source at some time. * - Multibyte - Oct 16, 2015 The code you provided is working fine for me:
* - Josh - Oct 16, 2015 Compress function literally stolen from another site... * - DeStilleGast - Oct 16, 2015 (Oct 16, 2015 07:56 AM)Multibyte Wrote: The code you provided is working fine for me:True, but it doesn't work work on BIG files ![]() (Oct 16, 2015 07:57 AM)Josh Wrote: Compress function literally stolen from another site...True, the code here is from an another site, I never said it was my code * - Dentmen - Oct 16, 2015 i bet its memory problem try junk cleaner or sumthing ram out of memory check your ram usage during this * - DeStilleGast - Oct 16, 2015 (Oct 16, 2015 08:40 AM)Dentmen Wrote: i bet its memory problem try junk cleaner or sumthing Correct, but I got already the solution, its your task to fix it. And if you can see, it is imposible to cleanup (with this sample) the memory. I got 8GB ram on this computer. and there is minimal 2GB free while it is compessing 600MB. So its not the problem with my RAM. * - Shoсkwave - Oct 16, 2015 Well, I don't really believe that this is a challenge. I believe you're just stuck and you're to proud to ask for help. Getting help is fine and nothing to be embarrassed of. Regardless here is my "solution" I split the file into 2mb chunks, compressed the chunk and appended it to the output file, very simple and only uses about 20k memory and ~12 CPU on my machine Code Imports System.IOI think the file I compressed was already compressed as it's from GTA's game resources. ![]() If you want I can comment the code, but it's pretty self explanitory. * - Odus - Oct 16, 2015 (Oct 16, 2015 09:22 AM)Shockwave™ Wrote: Well, I don't really believe that this is a challenge. I believe you're just stuck and you're to proud to ask for help. I'm with this as well. Post your solution. * - DeStilleGast - Oct 16, 2015 (Oct 16, 2015 09:22 AM)Shockwave™ Wrote: Well, I don't really believe that this is a challenge. I believe you're just stuck and you're to proud to ask for help.Then you haven't read the whole post, I know a solution that works. You can blame me if it isn't, but I got already a working code: Proof: ![]() (Used another recorder since my WIP recorder didn't work correct) And yes, I'm also a little bit curious how other people are using/fixing this. (Oct 16, 2015 09:29 AM)Odus Wrote: I'm with this as well. Post your solution. Aw but that ruins my challenge 😟 Code Using toOpen As Stream = IO.File.OpenRead(Arg)And to get the bytes from the Stream I got this function Code Private Function GetStreamAsByteArray(ByVal stream As System.IO.Stream) As Byte()Maybe not the best code, but it works fine for me ATM * - Odus - Oct 16, 2015 (Oct 16, 2015 09:52 AM)DeStilleGast Wrote: Aw but that ruins my challenge 😟 Most challenges actually come with the challenger's (right word?) solution. Those actually up for the challenge won't look and those who can't will try and improve using it. I've seen people make the challenge without and the thread quickly fills up with posts saying "just make it a help thread". That's why I asked you to post your solution. * - DeStilleGast - Oct 16, 2015 (Oct 16, 2015 10:11 AM)Odus Wrote: Most challenges actually come with the challenger's (right word?) solution. Those actually up for the challenge won't look and those who can't will try and improve using it. Kinda true what you said there.😵 * - BahNahNah - Oct 16, 2015 The error is self explanatory, you are trying to use too much memory. You should be using a file stream, not a memory stream. |