Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7185771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:29:20+00:00 2026-05-28T18:29:20+00:00

I am using a third-party networking library and in order to send a network

  • 0

I am using a third-party networking library and in order to send a network message I need to create a new instance of the NetworkMessage class. This is inefficient because the application needs to run very fast and there are a lot of messages sent around, so I am looking for a way to avoid dynamic memory allocation for every message.

If the NetworkMessage was a struct then we wouldn’t have a problem. Also I cannot store a number of precreated NetworkMessage instances because the message arguments can only be passed in the constructor and they cannot be altered later on. I cannot change anything in the NetworkMessage class as it is third party.

Is there a way to create a memory pool in C# and then use something similar to the placement new operator from C++ to create objects from that pool? ( I know that there is no placement new operator in C# ). I’m looking for a way to initialize a block of memory and then use chunks of that memory to create instances of the NetworkMessage class from that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:29:21+00:00Added an answer on May 28, 2026 at 6:29 pm

    Before we go on, one remark: memory allocation is super-efficient in .NET. It is not an expensive operation like it was in COM.

    That being said, I see two solutions:

    One thing you can do is to simply create a pool of NetworkMessage instances yourself. You can then take them and release them from the pool using a simple manager class.

    Another option is to use an inversion of control container such as Castle Windsor, Unity or NInject. Such containers handle dependency creation and object lifetime management for you.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a third party java library which spawns new JFrame windows. How
I'm using a third-party library that returns XML that is not valid, because it
I'm using a third-party library which accesses fonts through the GraphicsEnvironment: getAllFonts() call. This
I am using a third party code which uses OpenSSL Crypto library. Since OSX
I'm using a third party library which returns a data reader. I would like
How could it be possible to send int (not using third party libraries) via
we are using some third-party library that have some dependencies that must be referenced
I'm using third party library which compiled one week ago. Today I sat down
This is bit tough question. Im using third party library that will insert result
When using third-party libraries such as jquery, yui-reset, swfobject and so on, do you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.