473,395 Members | 1,466 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Dynamic memory allocation

Hi, i try to using unsafe programming to speed up my App.
i dont know how to dynamic memory allocate.

Anyone know it ?
Thanks,
Le Minh.
Oct 5 '06 #1
5 7124
Le Minh wrote:
Hi, i try to using unsafe programming to speed up my App.
i dont know how to dynamic memory allocate.

Anyone know it ?
Can you provide more details? What is it about your app that is slow and
how/why do you think using unsafe code will speed it up?
--
Tom Porterfield

Oct 5 '06 #2
My App is processing image. It use GDI+ and it so slow. I want to manipulate
image in byte stream and hope it will better, so i need pointer.
Oct 5 '06 #3
Are you saying you dont know how to use pointers and addresses?

if so:

int var = 5; //assigns 5 to a memory space the size of int bytes

int * ptr;

ptr = &var; // makes ptr a reference poiting to the memory space of
var....sp ptr = 5;

*ptr = 10; //sets the memory space that ptr points to, to
10.........now var also equals 10.
*ptr= null; //frees memory and also means var is now null

....er does that help?
"Le Minh" <ha*******@hotmail.comwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
My App is processing image. It use GDI+ and it so slow. I want to
manipulate image in byte stream and hope it will better, so i need
pointer.

Oct 5 '06 #4
Are you saying you dont know how to use pointers and addresses?
No, i want a memory allocation function. It maybe like malloc function in
C++.
Can we do the same in C#?
Thanks
Oct 5 '06 #5
>No, i want a memory allocation function. It maybe like malloc function in
>C++.
Can we do the same in C#?
What's wrong with using the new operator to create a new byte array
(or other suitable array type)?

The only other allocation operator in C# is stackalloc to allocate
memory from the stack.

Then there are the Marshal.Alloc methods for allocating memory from a
native heap.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 5 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Tom | last post by:
What I mean is why can I only allocate const size stuff on the stack in C++? If I want to allocate a variable amount I need to use the OS API (Win32 in my case). Thanks, Tom.
6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
6
by: Sandeep Chikkerur | last post by:
Hi, If the entire heap memory for dynamic allocation is not available, does the compiler always return NULL ? eg: char *s; s = (char *)malloc(...);
13
by: xian_hong2046 | last post by:
Hello, I think dynamic memory allocation is supposed to be used when one doesn't know in advance how much memory to allocate until run time. An example from Thinking in C++ is to dynamically...
11
by: toton | last post by:
Hi, I have little confusion about static memory allocation & dynamic allocation for a cluss member. I have class like class Bar{ public: explicit Bar(){ cout<<"bar default"<<endl; }
24
by: Ken | last post by:
In C programming, I want to know in what situations we should use static memory allocation instead of dynamic memory allocation. My understanding is that static memory allocation like using array...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
3
by: ranjeetasharma81 | last post by:
Hi all, I have a big C-cod, in which there are lots of dynamic memory allocation used. I want to replace dynamic memroy allocation by static arrays. The following are the problems that i am...
14
by: vivek | last post by:
i have some doubts on dynamic memory allocation and stacks and heaps where is the dynamic memory allocation used? in function calls there are some counters like "i" in the below function. Is...
10
by: swornavidhya.mahadevan | last post by:
Which allocation (Static / Dynamic) is suitable for the situation when we are trying to allocate for a overloaded memory when the memory is full and no space to allocate. What will happen if both...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.