473,594 Members | 2,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

heap memory allocation

1 New Member
(I started researching and using C# 2 days ago, so sorry if some of this is basic)

After much reading and other research I have the following concerns:

1) I need a large number of 64K buffers (as many as I can get) and they will last the life of the app.

2) These will be read/written to/from via win API's

3) They need to accessed via pointers (kept in a circular list)

4) I understand I can allocate them on the heap by using the "fixed" keyword and they will not be moved..

5) I also understand I can get and use pointers to them if I use "unsafe" code blocks. Outside of the need for careful code, is there any other problems that "unsafe" causes?

6) I also understand that these fixed buffers will not be managed by the garbage cleanup (the pointer will remain valid).

7) Is there any problems using a large amount of fixed heap? (I expect this will limit the amount of cleanup that can be done) How much heap does .net need to function etc?

8) using pinvoke, can i use these pointers the same way as I would of in c/c++ and avoid marshalling?

9) the win API functions use PVOID to both read and write data.

10) It seems that marshalling is often about allowing the operation and then copying the data to managed code.

11) I need to avoid any memory copying both to avoid time loss and duplicate memory.

12) the app will be moving many 100's of megabytes per second, so want to avoid hidden overheads.

Any help/comments you can provide on this would help. (The books I have don't seem to think I need to know this detail!)

Thanks,

Larry
Nov 19 '09 #1
0 1370

Sign in to post your reply or Sign up for a free account.

Similar topics

14
30083
by: Kevin Grigorenko | last post by:
Hello, I couldn't find an obvious answer to this in the FAQ. My basic question, is: Is there any difference in allocating on the heap versus the stack? If heap or stack implementation is not part of the standard, then just disregard this question. Here's some questions I'm confused about, and if you can add anything else, please do so! Is the stack limited for each program?
4
3805
by: Shailesh Humbad | last post by:
If a class has no constructor/destructor, is not part of an inheritance heirarchy, is not a template, and only contains members of integral types, then is it okay to allocate it off the heap? Is this bad style? For example: class myClass { public: int myInt;
17
5021
by: Jonas Rundberg | last post by:
Hi I just started with c++ and I'm a little bit confused where stuff go... Assume we have a class: class test { private: int arr; };
24
2853
by: arcticool | last post by:
I had an interview today and I got destroyed :( The question was why have a stack and a heap? I could answer all the practical stuff like value types live on the stack, enums are on the stack, as are structs, where classes are on the heap... when value types go out of scope the memory is re- allocated, object remain in memory waiting to be cleaned up by the garbage collector, etc, but he responded 'so why not just put say a class on the...
3
3446
by: toton | last post by:
Operator overloading has a sort syntax rather than member function call for stack based memory allocation. like complex<int> c1,c2,c3; c3= c1+c2; How the same can be applied to heap based memory allocation? like complex<int> * c1,*c2,*c3; i still want to do something like c3 = c1+c2 ; rether than *c3 = *c1+*c2;
16
4437
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area in RAM/Memory or does it refer to a data structure being used for storing objects. 2. In C++, functions and its local variables go in stack. If local variables that are primitives go in stack, it is OK. But what
10
3022
by: Pep | last post by:
I have a problem I need to solve which looks like memory exhaustion. Is there a function that I can use in c++ to determine the size of the heap before and after a allocation? The C++ code is running on linux and freeBSD. The actual library I am interfacing with uses malloc and i have no control over it so I need to see the state of the heap after each use of the libraries allocation functions.
0
1680
by: Le Minh | last post by:
I used this class to dynamic memory allocation: using System; using System.Runtime.InteropServices; public unsafe class Memory { // Handle for the process heap. This handle is used in all calls to the // HeapXXX APIs in the methods below. static int ph = GetProcessHeap(); // Private instance constructor to prevent instantiation. private Memory() {}
53
26352
by: fdmfdmfdm | last post by:
This is an interview question and I gave out my answer here, could you please check for me? Q. What are the memory allocation for static variable in a function, an automatic variable and global variable? My answer: static variable in function and global variable are allocated in head, and automatic variable is allocated in stack. Right?
11
5198
by: Andy Watson | last post by:
I have an application that scans and processes a bunch of text files. The content I'm pulling out and holding in memory is at least 200MB. I'd love to be able to tell the CPython virtual machine that I need a heap of, say 300MB up front rather than have it grow as needed. I've had a scan through the archives of comp.lang.python and the python docs but cannot find a way to do this. Is this possible to configure the PVM this way? ...
0
7936
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8241
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8227
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6646
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5402
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3853
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.