Les Partages de Memiks
Tag cloud
Picture wall
Daily
RSS Feed
  • RSS Feed
  • Daily Feed
  • Weekly Feed
  • Monthly Feed
Filters

Links per page

  • 20 links
  • 50 links
  • 100 links

Filters

Untagged links
10 results tagged memory  ✕
getting size of array from pointer c++ - Stack Overflow https://stackoverflow.com/questions/19894686/getting-size-of-array-from-pointer-c/19894884
Sat Feb 6 14:03:38 2021 archive.org
QRCode
thumbnail

C++ is based on C and inherits many features from it. In relation to this question, it inherits something called "array/pointer equivalence" which is a rule that allows an array to decay to a pointer, especially when being passed as a function argument. It doesn't mean that an array is a pointer, it just means that it can decay to one.

void func(int ptr); int array[5]; int ptr = array; // valid, equivalent to 'ptr = &array[0]' func(array); // equivalent to func(&array[0]);

This last part is the most relevant to your question. You are not passing the array, you are passing the address of the 0th element.

In order for your function to know how big the incoming array is, you will need to send that information as an argument.

static const size_t ArraySize = 5; int array[ArraySize]; func(array, ArraySize);

Because the pointer contains no size information, you can't use sizeof.

void func(int* array) { std::cout << sizeof(array) << "\n"; }

This will output the size of "int*" - which is 4 or 8 bytes depending on 32 vs 64 bits.

Instead you need to accept the size parameters

void func(int* array, size_t arraySize); static const size_t ArraySize = 5; int array[ArraySize]; func(array, ArraySize);

Even if you try to pass a fixed-sized array, it turns out this is syntactic sugar:

void func(int array[5]);

http://ideone.com/gaSl6J

Remember how I said that an array is NOT a pointer, just equivalent?

int array[5]; int* ptr = array; std::cout << "array size " << sizeof(array) << std::endl; std::cout << "ptr size " << sizeof(ptr) << str::endl;

array size will be 5 sizeof(int) = 20 ptr size will be sizeof(int ) which will be either 4 or 8 bytes.

sizeof returns the size of the type being supplied, if you supply an object then it deduces the type and returns the size of that

If you want to know how many elements of an array are in the array, when you have the array and not a pointer, you can write

sizeof(array) / sizeof(array[0])

or sizeof(array) / sizeof(*array)

cpp pointer sizeof memory
getting size of array from pointer c++ - Stack Overflow https://stackoverflow.com/questions/19894686/getting-size-of-array-from-pointer-c/19894884
Sat Feb 6 14:03:38 2021 archive.org
QRCode
thumbnail

I am writing a simple function that returns the largest integer in an array. The problem I am having is finding the number of elements in the array.

Here is the function header:

int largest(int ...

cpp pointer sizeof memory
Dynamic Allocation in Classes https://www.cs.fsu.edu/~myers/cop3330/notes/dma.html
Sat Feb 6 14:01:18 2021 archive.org
QRCode
cpp memory alloc
Want to Remember Everything You'll Ever Learn? Surrender to This Algorithm https://www.wired.com/2008/04/ff-wozniak/
Wed Aug 8 14:41:28 2018 archive.org
QRCode
thumbnail

Illustration: Steven Wilson The winter sun sets in mid-afternoon in Kolobrzeg, Poland, but the early twilight does not deter people from taking their regular outdoor promenade. Bundled up in parkas with fur-trimmed hoods, strolling hand in mittened hand along the edge of the Baltic Sea, off-season tourists from Germany stop openmouthed when they see a tall, […]

memory
VisualVM: Monitoring Remote JVM Over SSH (JMX Or Not) | Javalobby http://java.dzone.com/articles/visualvm-monitoring-remote-jvm
Mon May 11 21:45:30 2015 archive.org
QRCode
thumbnail

Comment utiliser visualVM à travers un pont SSH ?

par un proxy socks:

ssh -D 9096 user@host

ensuite tools -> options -> network -> proxy socks -> localhost:9096

visualvm ssh proxy socks java jvm jmx memory
Does Java 6 open a default port for JMX remote connections? - Stack Overflow http://stackoverflow.com/questions/516142/does-java-6-open-a-default-port-for-jmx-remote-connections
Mon May 11 21:42:56 2015 archive.org
QRCode
thumbnail

Comment est géré la connection en JMX au instances de JVM afin d'avoir des infos sur la jvm, la taille mémoire, les objets, etc... ?

java jvm jmx memory instance
Java, memory leak et PermGen space error - 30 minutes par jour http://30minparjour.la-bnbox.fr/2012/java-memory-leak-et-les-erreurs-de-permgen-space
Tue Mar 19 22:52:06 2013 archive.org
QRCode
thumbnail

Un bon article pour comprendre ce qu'est une fuite mémoire et comment y remédier ;)

memoire java perm gen space memory leak fuite
High-Performance, Garbage-Collector-Friendly Code - Build New Games http://buildnewgames.com/garbage-collector-friendly-code/
Thu Sep 20 17:12:06 2012 archive.org
QRCode
thumbnail

un article parlant du garbage collector en javascript.

peu connu, le javascript utilise comme son cousin java, un garbage collector, c'est à dire un processus régulier qui va vérifier si les variables sont encore utilisées, si ce n'est pas le cas il les suppriment.
et du coup il permet de récupérer de la mémoire.

il va falloir que je lise attentivement cet article, utilisant de manière intensive Javascript dans mon travail

(via http://linuxfr.org/users/crev/journaux/de-tout-de-rien-des-bookmarks-du-bla-bla--5 de CrEv)

javascript garbage collector java memory
Analyzing large heap dumps with MAT on Windows » ghidinelli.com http://www.ghidinelli.com/2009/07/30/large-heap-dumps-eclipse-mat
Fri Jan 20 20:29:54 2012 archive.org
QRCode
thumbnail

Ouvrir les heap dumps trop gros pour la config pas défaut de Memory Analyser ou de windows XP

windows memory analyse heap dump
Understanding Apple's Binary Protection in Mac OS X http://osxbook.com/book/bonus/chapter7/binaryprotection/
Thu Oct 20 07:02:35 2011 archive.org
QRCode
thumbnail

Mac OS X Internals

Amit Singh Mac OS X Internals 0321278542 Apple History Operating Systems Classic Rhapsody NEXTSTEP OPENSTEP BeOS Windows Mach Accent RIG dyld Open Firmware EFI Extensible Interface Virtual Memory Processes Process Management Scheduling Processors BSD O Kit Device Drivers Object oriented Interrupts Motion Sensor HFS File Interprocess Communication Ports
4759 links, including 1673 private
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Theme by kalvn