• January 22, 2022, 09:15:05 pm

Author Topic: Just because...  (Read 2691 times)

ben_fb

  • Addict
  • *****
  • Posts: 246
Just because...
« on: April 10, 2011, 09:25:51 am »

Gave up VB6 a couple weeks ago and started learning VB2010, after understanding more of the language I will probably be switching to C#.
If anyone wants the following ... I will be releasing it open source upon completion.

Code: [Select]
[09:22:01 AM] test.kry_x2#428 is using Starcraft Broodwar in a private channel.
This post has been thanked 1 time pikachu

Scope

  • Founder
  • Main Administrator
  • Hero Member
  • *******
  • Posts: 3,143
    • BnetWeb
Re: Just because...
« Reply #1 on: April 10, 2011, 03:05:47 pm »
C# is my preferred language. Thats what Reticle is programmed in. Plus more knowledgeable people use C#. More helpful topics on the subject, not to mention pianka, mike, and warrior all rock it pretty well, making it even better for Battle.net development ;)

"Capitalization is the difference between helping your Uncle Jack off a horse and helping your uncle jack off a horse."

warrior

  • Sr. Member
  • ******
  • Posts: 409
  • Jesus Christ.
Re: Just because...
« Reply #2 on: April 11, 2011, 06:26:42 pm »
any c# issues feel free to post here, I still check from time to time ..
In capitalist America, bank robs you.

Choosing to code in an unmanaged language/platform is like choosing a hotel where you have to clean your own room.

When C++ is your hammer, everything starts to look like your thumb

ben_fb

  • Addict
  • *****
  • Posts: 246
Re: Just because...
« Reply #3 on: April 11, 2011, 06:47:16 pm »
thanks, I don't think I will be working on any projects in the near future though. I also scrapped Kry X2 after seeing the RAM use, roughly 150,000 K for 400 bots ... and that was with hardly any features and everything being disposed. I was told vb.net is a ram hog but I wasn't expecting it to be that bad...

warrior

  • Sr. Member
  • ******
  • Posts: 409
  • Jesus Christ.
Re: Just because...
« Reply #4 on: April 11, 2011, 06:55:14 pm »
How much of that was shared .NET memory which is the same for every process? You do know about shared memory right?
In capitalist America, bank robs you.

Choosing to code in an unmanaged language/platform is like choosing a hotel where you have to clean your own room.

When C++ is your hammer, everything starts to look like your thumb

ben_fb

  • Addict
  • *****
  • Posts: 246
Re: Just because...
« Reply #5 on: April 11, 2011, 10:40:07 pm »
I would assume most of it. Even after all MBNCSUtil calls are finished and all packets disposed the RAM use remains high. There is hardly any code to the project, the only thing that spawns and sticks if the sockets which is under 40 lines of code per bot. It could be the async sockets but who know. Shared memory or not it's stupid to consume that much.

warrior

  • Sr. Member
  • ******
  • Posts: 409
  • Jesus Christ.
Re: Just because...
« Reply #6 on: April 11, 2011, 10:44:38 pm »
Its a price paid for all running .NET instances, chances are on a modern system, you're not the only application pulling in the .NET framework, so the memory cost is probably paid for anyway. Using ProcessExplorer you can get a more detailed breakdown of memory allocations.

Hell, if you're still curious you can do memory profiling and get a breakdown even by Garbage Collector generations. From there you can see what objects you have are living the longest (or not being collected at all, hence memory leaks .. and it may very well be undisposed sockets since you're creating something like 400 handles, it could be threads, each with their own address space, depending on how scalable your threads are, things like that .. )

I'd suggest profiling, because your numbers seem a bit abnormal to me, and it'll be a good learning experience. Also, dont assume MBNCSUtil and the like are saints either :) actually, dont assume anything. Profile, profile, profile.
In capitalist America, bank robs you.

Choosing to code in an unmanaged language/platform is like choosing a hotel where you have to clean your own room.

When C++ is your hammer, everything starts to look like your thumb

ben_fb

  • Addict
  • *****
  • Posts: 246
Re: Just because...
« Reply #7 on: April 12, 2011, 10:15:11 am »
What's generating the most CPU use is the calls to the sockets, even though I'm only making 3 a second(at least to make the initial -Connect To- call). What's consuming the most ram is a byte[] type variable, which also probably relates to the sockets since I'm handling everything with them as bytes. Was looking into the Call Stack debugging option but it just presents a white box with no information, I may have to pause the project to collect the data or something of that sort ... but as of right now I have to head to work ... fun fun.

warrior

  • Sr. Member
  • ******
  • Posts: 409
  • Jesus Christ.
Re: Just because...
« Reply #8 on: April 14, 2011, 12:01:24 am »
Are you using the desktop .NET Framework? If so you seem to have pretty perfect scenarios for multicore parallelism. blogs.msdn.com/pfxteam is the blog for the Task Parallel Library in .NET4+ so if you're interested you can read a lot of good articles both there and on MSDN. Should reduce your CPU usage, or at least balance it out among a few cores as opposed to saturating one core.

As for byte[]s you should make sure you're not needlessly keeping them in memory, make sure the objects which hold the reference to the byte[]s are being disposed of, or even their parents which hold a reference to them, etc.

ESPECIALLY when you deal with sockets, if you dont dispose of them when you're done, you're leaking memory all over the place.
Of course, think about it logically, for however many connections you have, inevitable you're going to use some buffers so it may in the end be an unavoidable cost.

Did you notice that the sum of your allocated memory in the profiler is less than what taskmanager says? Try using ProcessExplorer to see the "real" memory usage. You subtract shared memory usage from total memory usage.

Btw: Kudos for actually profiling. +1
In capitalist America, bank robs you.

Choosing to code in an unmanaged language/platform is like choosing a hotel where you have to clean your own room.

When C++ is your hammer, everything starts to look like your thumb

 

newBalance by DzinerStudio