How do I read an entire file into a std::string in C++?

How do I read a file into a std::string, i.e., read the whole file at once? Text or binary mode should be specified by the caller. The solution should be standard-compliant, portable and...

memory leak problems

I used _CRTDBG_MAP_ALLOC and put _CrtDumpMemoryLeaks() at the program exit to detect memory leak, and got the following memory leak report: Detected memory leaks! Dumping objects...

What are the similarities between the Java memory model and the C++11 memory model?

The new c++ standard introduces the notion of a memory model. There were already questions on SO about it, what does it mean, how does it change the way we write code in c++ and so on. I'm...

How do I access memory from one program in another

I have a closed-source 3rd party program, and I want to be able to Know what memory is allocated to the program Access that memory (read only is fine) Utilities like vmmap(1), heap(1), and...

Instruction reordering & happens-before relationship in java

In the book Java Concurrency In Practice, we are told several time that the instructions of our program can be reordered, either by the compiler, by the JVM at runtime, or even by the processor....

Lazy sequence generation in Rust

How can I create what other languages call a lazy sequence or a "generator" function? In Python, I can use yield as in the following example (from Python's docs) to lazily generate a sequence that...

Is there a CUDA smart pointer?

If not, what is the standard way to free up cudaMalloced memory when an exception is thrown? (Note that I am unable to use Thrust.)

Warning: simplexml_load_string(): Memory allocation failed : growing buffer

Following code is used to convert an XLSX file to CSV using PHPExcel: <?php require_once 'PHPExcel/PHPExcel/IOFactory.php'; $excel = PHPExcel_IOFactory::load("test123.xlsx"); $writer...

Malloc a 2D array in C

Every time I allocate the memory for a 2D array first I create an array of int** and then with a for I allocate the memory for each element. For example: int ** arr = malloc(N*sizeof(int...

In memory MySQL table vs Redis, about insert and concurrency performance

Since data is stored in memory in both cases, is it possible to have the same approximative insert/s and concurrency performance for both? If not, why?

What does `UnsafeMutablePointer.initialize()`actually do?

The following is base on my guess. Someone please point out the parts that I understand incorrectly. If I have a class, of which an instance occupies 128 bits, called Class128Bits. And my program...

File manager detects Android device but gvfs folder is empty. How can I access the MTP device from terminal?

Directories /run/user/1000/gvfs and ~/.gvfs are emtpy and non-existing, respectively. My graphical file manager (Thunar) is able to detect and access the internal and external memory of the...

A lot of java.util.zip.ZipFile$ZipFileInputStream objects/ Same jars loaded multiple times

I am checking a heap dump of an Tomcat application which tends to crash when it has increased load right after startup. During the crash I observe an increasing number of unsuccessful attempts to...

Managing threads while practicing modern c++17's best practices

Originally I had thought about designing a ThreadManager class to store threads along with the data type objects and function type objects that they would work with. The class was to be...

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

I've just recently moved my websites from apache2 to Nginx as my new web server backend. got to love problems aha. HTML files in the web host director work prior to php files making there way main...

Docker on Linux: All actions (hello-world, pull image, etc) yield timeouts

I know this is a common question, but I've spent two hours trying to get past docker run hello-world and am totally stumped. Everything I try yields a net/http waiting for connection...

Microsoft Graph AD Users or people API to search all users?

I'm trying to build functionality into my app for 'admins' to assign users from their AD group to certain groups that are further assigned to app-specific roles. Basically a simple management...

Troubleshooting Java memory usage exception

I'm trying to troubleshoot a Java program that requires increasingly more memory until it cannot allocate any more and then it crashes. EDIT More information about the program. The program is an...

Getting "Unable to check for available memory." on Oracle DB 18c

I am trying to create a database in order to complete my self learning, but unfortunately I got unexpected error "Unable to check for available memory.", I am doing it using Database Configuration...

s3.getObject().promise() never returns anything

If use this code within a Lambda which complies with everything I read on stackoverflow and on the AWS SDK documentation. However, it neither returns anything nor throws an error. The code is...

How to display the memory usage in GB instead of percent by htop in ubuntu

Is there any way to get the RAM used by each process in GB rather than in % by htop in ubuntu?

AWS ECS fargate task stopping and restarting somewhat randomnly

One of my ECS fargate tasks is stopping and restarting in what seems to be a somewhat random fashion. I started the task in Dec 2019 and it has stopped/restarted three times since then. I've found...

What does sh:1:start:not found mean?

I am making a raspberry pi chatbot using google text to speech. Here is my code: import os from gtts import gTTS import time text_to_read = "Hello my name is Alex. What's your name? " language...

Display errors in MySQL Workbench

MySQL Workbench is displaying a series of boxes instead of characters in the results screen, and a number of elements are disappearing from the window when a query is run. I'm receiving a number...

How to reuse Stack Allocator in RapidJSON without reallocating memory

I'm running a single-threaded system in FreeRTOS with limited resources. I already preallocate buffers for the RapidJSON allocators as so: char valueBuffer[2048]; char...

Reduce memory usage of AVAssetWriter

As the title says, I am having some trouble with AVAssetWriter and memory. Some notes about my environment/requirements: I am NOT using ARC, but if there is a way to simply use it and get it all...

What are the files boot_app0.bin and bootloader_dio_80m.bin for? (ESP32 - Arduino IDE)

The ESP32 flash command, as executed by the Arduino IDE, seems to flash two bootloader files: boot_app0.bin at offset 0xe000 and bootloader_dio_80m.bin at offset 0x1000. I wonder what these two...

Configure cloudwatch agent to get metrics from collectd

I am trying to send few metrics to cloudwatch using collectd and cloudwatch agent. Below are the steps i did. Installed collectd agent Enabled few plugins from /etc/collectd.conf (cpu, memory,...

How to create a subrange of a BTreeSet<(String, String, String)>? How to turn a tuple of bounds into a bound of a tuple?

I am trying to use a BTreeSet<(String, String, String)> as a way to create a simple in-memory 'triple store'. To be precise: type Entity = String; type Attribute = String; type Value =...

Inference using saved model in Tensorflow 2: how to control in/output?

Adapting my code from TF1 to TF2.6 I run into trouble. I am trying to add some custom layers to an inception resnet, save the model, and then load and run it. from tensorflow.keras.layers import...