memory

Why do compilers allow string literals not to be const?

喜欢而已 提交于 2020-01-07 03:04:06
问题 And where are literals in memory exactly? (see examples below) I cannot modify a literal, so it would supposedly be a const char*, although the compiler let me use a char* for it, I have no warnings even with most of the compiler flags. Whereas an implicit cast of a const char* type to a char* type gives me a warning, see below (tested on GCC, but it behaves similarly on VC++2010). Also, if I modify the value of a const char (with a trick below where GCC would better give me a warning for),

Run time overhead of compiler barrier in gcc for x86 processors

北城余情 提交于 2020-01-07 02:52:04
问题 I was looking into the side effects/run time overhead of using compiler barrier ( in gcc ) in x86 env. Compiler barrier: asm volatile( ::: "memory" ) GCC documentation tells something interesting ( https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html ) Excerpt: The "memory" clobber tells the compiler that the assembly code performs memory reads or writes to items other than those listed in the input and output operands (for example, accessing the memory pointed to by one of the input

Android Webview JNI ERROR with loadUrl

徘徊边缘 提交于 2020-01-07 01:58:07
问题 I'm writing an Android App which is opening a locally stored html file check.html . This html file is showing some nice text and then http-forwarding to my real wanted webpage. Now it can happen, that the server is down, or even the network is unplugged, but I want the app to keep trying to reach it all the time. In case that just the server is down, Android has some latency when asking for the webpage before returning to onReceivedError() , so I don't have a problem, but if the network is

Memory Leak with no dynamic memory

て烟熏妆下的殇ゞ 提交于 2020-01-07 00:08:18
问题 I was wondering if you you could have a memory leak on the heap without having any dynamic memory allocated. However, I do have three vectors declared and initialized. Is it because I need to deallocate the vector before I close the program. 回答1: I just found the problem, it was the exit function that I was using to close the program. exit does not call the destructors of any stack based objects so if those objects have allocated any memory internally then yes that memory will be leaked.

C - pointer being freed was not allocated

蹲街弑〆低调 提交于 2020-01-06 20:29:06
问题 I am trying to free a pointer that I assigned from a vector allocated with malloc() , when I try to remove the first element(index [0]), it works, when I try to remove the second(index [1]) I receive this error: malloc: *** error for object 0x100200218: pointer being freed was not allocated The code: table->t = malloc (sizeof (entry) * tam); entry * elem = &table->t[1]; free(elem); 回答1: You can only call (or need to) free() on the pointer returned by malloc() and family. Quoting C11 , chapter

Memory Error Python Processing Large File Line by Line

老子叫甜甜 提交于 2020-01-06 20:12:31
问题 I am trying to concatenate model output files, the model run was broken up in 5 and each output corresponds to one of those partial run, due to the way the software outputs to file it start relabelling from 0 on each of the file outputs. I wrote some code to: 1) concatenate all the output files together 2) edit the merged file to re-label all timesteps, starting at 0 and increasing by an increment at each one. The aim is that I can load this single file into my visualization software in one

数据库:存储引擎+InnoDB+TokuDB+ MyIASM +Memory+索引+三范式等

余生长醉 提交于 2020-01-06 20:11:10
存储引擎 概念 数据库存储引擎是数据库底层软件组织,数据库管理系统(DBMS)使用数据引擎进行创建、查询、更新和删除数据。不同的存储引擎提供不同的存储机制、索引技巧、锁定水平等功能,使用不同的存储引擎,还可以 获得特定的功能。现在许多不同的数据库管理系统都支持多种不同的数据引擎。 存储引擎主要有: 1. MyIsam , 2. InnoDB, 3. Memory, 4. Archive, 5. Federated 。 InnoDB(B+树) InnoDB 底层存储结构为B+树, B树的每个节点对应innodb的一个page,page大小是固定的,一般设为 16k。其中非叶子节点只有键值,叶子节点包含完成数据。 数据库:存储引擎+InnoDB+TokuDB+ MyIASM +Memory+索引+三范式等 适用场景 : 1)经常更新的表,适合处理多重并发的更新请求。 2)支持事务。 3)可以从灾难中恢复(通过 bin-log 日志等)。 4)外键约束。只有他支持外键。 5)支持自动增加列属性 auto_increment。 TokuDB(Fractal Tree-节点带数据) TokuDB 底层存储结构为 Fractal Tree,Fractal Tree 的结构与 B+树有些类似, 在 Fractal Tree中,每一个 child 指针除了需要指向一个 child 节点外

For loop stops for no reason

扶醉桌前 提交于 2020-01-06 19:57:29
问题 So I'm trying to make a program to read a ppm file and store it in memory, I've got everything working up to the colors, this function is giving me problems: typedef struct{ int red, green, blue; } COLOR; COLOR * getNextColor(FILE *fd); COLOR **getColors(FILE *fd, int width, int height){ printf("\nentered get colors"); COLOR **colors = malloc(sizeof(COLOR*)*height); printf("\nallocated %d space height",height); int i,j; for(i = 0; i < height; i++, colors++){ *colors = malloc(sizeof(COLOR)

Why is the string specified in `LD_PRELOAD` loaded on the memory of setuid executables in RedHat 6.2?

我与影子孤独终老i 提交于 2020-01-06 19:54:44
问题 First of all, let me tell you the context. I'm solving problems of the wargame called The lord of the BoF , which is based on RedHat Linux 6.2 , which has no address space layout randomization(ASLR) , NX bit , ASCII armor , etc.. And the gcc there does not make any dummy when it compiles code. When I was trying to solve the problem called golem , I wondered something. The solving log This is the source code of the golem . As you can see, it fills the entire stack with 0 , except for the

Javafx growing memory usage when drawing image

邮差的信 提交于 2020-01-06 19:37:26
问题 I'm creating a quite simple Go board game in JavaFX. I stumbled on growing memory usage in my application and after reducing everything unnecessary, it appeared that even the minimal example causes huge memory growth overtime, its about 50 to 100MB/s . Here's the code: import javafx.animation.AnimationTimer; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx