Hello!
I'm having some issues with producing an int matrix without creating memory leaks. I want to be able to make a given (global) matrix into any size dynamically via read_matrix(). But then i want to be able to free the memory later on. So in my main method the second printf should result in a bus error since it should not have any ...
I know how to create an array of structs but with a predefined size. However is there a way to create a dynamic array of structs such that the array could get bigger?
For example:
typedef struct
{
char *str;
} words;
main()
{
words x[100]; // I do not want to use this, I want to dynamic increase the...
What are the ways to reduce the amount of memory my applications take in RAM?..Because even 30kb application loads ~20Mb of "unneeded" dlls.Am i mistaking when i think that any .NET app takes at least 10Mb in working set of memory when we need a form with text in it? Couldn't find any explanation of this :(
PS
question is closed. But i...
What are the differences between the following constructs? Why prefer one over the other?
Dim byteArray(20) as Byte
and
Dim byteArray() as Byte = new Byte(20) {}
Edit - Corrected the ReDim. Should be a Dim.
...
Hello, I have a C++ memory management doubt, that's (obviously) related to references and pointers. Suppose I have a class Class with a method my_method:
OtherClass& Class::my_method( ... ) {
OtherClass* other_object = new OtherClass( ... );
return *other_object;
}
Meanwhile in a nearby piece of code:
{
Class m( ... );
...
What is the difference between System.GetMem and System.ReallocMem?
Delphi 2009 Help for ReallocMem, is exactly the same description of GetMem.
How about System.FreeMem and System.Dispose
What should I use with arrays?
type
PMemberDataList = ^TMemberDataList;
TMemberDataList = array[0..MaxClassMembers -1] of PMemberData;
var
F...
how allocate memory dynamically for the array of stucture....
eg:
class students
{
struct stud
{
int r_no;
char name[20];
}*s;
}
how to allocate memory dynamically for *s...
...
Last week I wrote a few lines of code in C# to fire up a large text file (300,000 lines) into a Dictionary. It took ten minutes to write and it executed in less than a second.
Now I'm converting that piece of code into C++ (because I need it in an old C++ COM object). I've spent two days on it this far. :-( Although the productivity di...
Hi, I have a question about the std::vector.
I have a very memory intensive algorithm where I forsee that predicting vector sizes and reserving enough memory for the vectors in advance will help me a lot with reducing memory usage.
Which of the following is better:
for ( ... ) {
std::vector<Type> my_vector;
my_vector.reserve(stuff...
I would like to pass some (dll or not) function pointers as arguments to some dll functions and call them from inside of the dll. I wonder if it is safe because I have found an information on http://publib.boulder.ibm.com/infocenter/zos/v1r10/index.jsp?topic=/com.ibm.zos.r10.cbcpx01/fpref.htm that:
In DLL code, it is assumed that a func...
After four weeks of learning Objective-C for the iPhone, my first useful application is almost finished. However, I still need to save several instance variables whenever the current view is changed and to reload them when the view is reopened.
I have no trouble loading variables with basic C types like int and BOOL, but am having diffi...
Hello,
I have a very basic question and need help.
I am trying to understand what is the scope of a dynamically allocated memory (on heap).
#include <stdio.h>
#include <malloc.h>
//-----Struct def-------
struct node {
int x;
int y;
};
//------GLOBAL DATA------
//-----FUNC DEFINITION----
void funct(){
t->x = 5; //**can I...
#define IMGX 8192
#define IMGY 8192
int red_freq[256];
char img[IMGY][IMGX][3];
main(){
int i, j;
long long total;
long long redness;
for (i = 0; i < 256; i++)
red_freq[i] = 0;
for (i = 0; i < IMGY; i++)
for (j = 0; j < IMGX; j++)
red_freq[img[i][j][0]] += 1;
total = 0;
for (i = 0; i < 256; i++)
to...
I am compiling a C program with the SPARC RTEMS C compiler.
Using the Xlinker -M option, I am able to get a large memory map with a lot of things I don't recognize.
I have also tried using the RCC nm utility, which returns a slightly more readable symbol table. I assume that the location given by this utility for, say, printf, is the l...
What does lazy allocation of objects mean and how is it useful?
...
I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:
# (1)
for k in range(4..20):
# (2)
input = generate 2**k random points
for variant in variants:
benchmark the following call
run variant on input array
# (3)
Is it possible to reset the whole he...
I am developping on Windows with DevStudio, in C/C++ unmanaged.
I want to allocate some memory on the stack instead of the heap because I don't want to have to deal with releasing that memory manually (I know about smart pointers and all those things. I have a very specific case of memory allocation I need to deal with), similar to the ...
Is there a way to define a macro (or something similar) that would allow objects to be allocated on the stack or on the heap, cleanly?
eg.
Current code:
A a;
a.someFunc();
The simplest suggestion might be the following, but as you can see below, it's not very clean to maintain 2 sets of code.
#ifdef USE_STACK
A a;
a.someFunc();...
I'm trying to store a pointer in an array.
My pointer to a pointer is class object is:
classType **ClassObject;
So i know i can allocate it by using the new operator like this:
ClassObject = new *classType[ 100 ] = {};
I'm reading a text file, with punctuation and here is what i have so far:
// included libraries
// main function...
What tools are available to attribute memory consumptions in VB6 application to it's multiple components?
I can get the memory consumed by the entire application by watching various counters (Private Bytes, Working Set etc.), for example, in Process Explorer. I want to go level deeper than that and understand how much memory is consumed ...