memory-leaks

Memory leaks in pthread even if the state is detached

穿精又带淫゛_ 提交于 2021-01-29 18:37:55
问题 I am learning pthreads programming. I understood that there are two states of thread: 1. Joinable 2. Detachable In case of Joinable, we need to call pthread_join to free the resources(stack), whereas in case of detached there is no need to call pthread_join and the resources will be freed on thread exit. I wrote a sample program to observe the behavior #include <stdio.h> #include <pthread.h> #include <stdlib.h> void *threadFn(void *arg) { pthread_detach(pthread_self()); sleep(1); printf(

How to correctly subscribe Angular HttpClient Observable?

感情迁移 提交于 2021-01-29 13:55:37
问题 Taking example of HeroService from angular documentation. Below is a POST method in HeroService addHero (hero: Hero): Observable<Hero> { return this.http.post<Hero>(this.heroesUrl, hero, httpOptions) .pipe( catchError(this.handleError('addHero', hero)) ); } We can see that every time addHero is called a new Observable is returned. Ok now here is the service call from HeroComponent this.heroesService .addHero(newHero) .subscribe(hero => this.heroes.push(hero)); Now In my component this add

OpenCL clCreateContextFromType function results in memory leaks

旧街凉风 提交于 2021-01-29 12:16:56
问题 I ran valgrind to one of my open-source OpenCL codes (https://github.com/fangq/mmc), and it detected a lot of memory leaks in the OpenCL host code. Most of those pointed back to the line where I created the context object using clCreateContextFromType . I double checked all my OpenCL variables, command queues, kernels and programs, and made sure that they are all properly released, but still, when testing on sample programs, every call to the mmc_run_cl() function bumps up memory by 300MB

mysqli_query single query gerenating PHP fatal error: Allowed memory size exhausted

ぃ、小莉子 提交于 2021-01-29 10:25:58
问题 I have a Mysql table (named "base") with 3 million records , which is composed of only 3 int(10) fields . When I try to run this simple query $result = mysqli_query($db, 'SELECT * FROM base') , php shows the error: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 10485768 bytes) in C:\xampp\htdocs\combina.php on line 17 I think mysqli_query should not load all the table records into memory, right? So why the memory overflow? I'm using XAMPP installation on

valgrind shows memory leak even after memory free

坚强是说给别人听的谎言 提交于 2021-01-29 06:30:03
问题 so I have the file Countries.c which contains: typedef struct City* pCity; typedef struct Country* pCountry; typedef struct Territory* pTerritory; struct City{ char* name; char* food; int population; }; struct Country{ char *name; int numCities; pCity cities; pTerritory countryTerr; }; struct Territory{ int x1; int x2; int y1; int y2; }; void deleteCountry(pCountry country){ if(country != NULL){ int num_of_cities = country->numCities; for(int i = 0 ; i<num_of_cities; i++){ if (country->cities

valgrind shows memory leak even after memory free

我与影子孤独终老i 提交于 2021-01-29 06:23:40
问题 so I have the file Countries.c which contains: typedef struct City* pCity; typedef struct Country* pCountry; typedef struct Territory* pTerritory; struct City{ char* name; char* food; int population; }; struct Country{ char *name; int numCities; pCity cities; pTerritory countryTerr; }; struct Territory{ int x1; int x2; int y1; int y2; }; void deleteCountry(pCountry country){ if(country != NULL){ int num_of_cities = country->numCities; for(int i = 0 ; i<num_of_cities; i++){ if (country->cities

Assigning unsigned char* buffer to a string

喜你入骨 提交于 2021-01-29 06:03:20
问题 This question might be asked before but I couldn't find exactly what I need. My problem is, I have a buffer loaded by data downloaded from a webservice. The buffer is in unsigned char* form in which there is no '\0' at the end. Then I have a poco xml parser needs a string. I tried assigning it to string valgrind found some lost data. (see below) here is the code: DOMParser::DOMParser(unsigned char* consatData, int consatDataSize, unsigned char* lagData, int lagDataSize) { Poco::XML::DOMParser

JVM “EXCEPTION_ACCESS_VIOLATION” crash in Spring Boot application

南笙酒味 提交于 2021-01-29 05:40:25
问题 JVM Crash - "EXCEPTION_ACCESS_VIOLATION" I made this CLI tool using Spring Boot and it takes a long time to run. I usually let it run overnight. Then, for several times I came across this JVM crash, and I don't know what to look for in there. I have seen other error reports on SO, but could not relate those to mine. Can you please take a look at this log file? Bear in mind I have been having problems with memory leak in the app... I have started suffering from this error when I thought I had

PrintTicket DllHost.exe Memory Climbs

假装没事ソ 提交于 2021-01-29 05:25:28
问题 I'm using PrintTickets to print a large number of WPF objects and things are printing fine. We do have a situation that has been reported where the program is using a ton of the dllhost.exe memory and climbs until the machine eventually crashes. I've narrowed it down to creating a PrintTicket and the printqueue.getprintcapabilitiesasxml() . Each time these are called it jumps the memory usage of the dllhost.exe each time by sometimes 3+ MB. Can anyone tell me either how to avoid this if

What is the max addressable memory space in a 32-bit C++ program?

走远了吗. 提交于 2021-01-28 08:39:44
问题 In debug mode I saw that the pointers have addresses like 0x01210040, but as I realized, 0x means hexadecimal right? And there're 8 hex digits, i.e. in total there're are 128 bits that are addressed?? So does that mean that for 32-bit system the first two digits are always 0, and for a 64-bit system the first digit is 0? Also, may I ask that, for a 32-bit program, would I be able to allocate as much as 3GB of memory as long as I remain in the heap and use only malloc()? Or is there some