duangsuse::Echo
725 subscribers
4.31K photos
131 videos
583 files
6.57K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
你的菜我完全佩服
不能更佩服
别人都对你表示无语了
开源是什么能吃吗
open source? is that edible?
绿色化,后台纯净
语法规范

主要是程序自动cocel
不然很容易导致内存溢出

我这个手机就已经溢出了
没溢出的时候玩游戏贼流畅
现在溢出了,聊QQ都卡出翔
#然后我就怼了几句
所以我突然在思考
内存溢出是啥
is that edible?
JVM 应用有啥典型的溢出情况
Python 呢
#小白回
语法不规范导致的进程不在运行后所申请的内存仍然被使用

RefCount GC 为什么不能清理循环引用导致内存溢出
循环引用是什么
为什么我们需要 JVM 使用 CMS 而不是快速优雅简单的 Rc(滑稽问号)

因为我们需要循环引用

class A {
B b;
public A(B bb) { b = bb; }
}
class B {
public A a;
public B() {}
}
B bb = new B();
A aa = new A(bb);
bb.a = aa;
补充:我怼的时候其实混淆了内存泄漏和内存溢出...
This media is not supported in your browser
VIEW IN TELEGRAM
说实话,其实我也不是大佬。但看到这种菜还特别自以为是的就非常想讽刺一下
duangsues.is_a? SaltedFish
说实话,其实我也不是大佬。但看到这种菜还特别自以为是的就非常想讽刺一下
#PL #Lowlvl_backend 看了一点帖子后科普一下
内存溢出就是内存越界

#include <stdio.h>

int main(int argc, char **argv) {
int ary[2] = {233, 666};
printf("%i, %i, %i, %i\n", ary[0], ary[1], ary[-1], ary[2]);
}


dse@susepc:~$ clang -Wall -Wextra b.c -o bbb
b.c:3:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char **argv) {
^
b.c:3:27: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char **argv) {
^
b.c:5:46: warning: array index -1 is before the beginning of the array [-Warray-bounds]
printf("%i, %i, %i, %i\n", ary[0], ary[1], ary[-1], ary[2]);
^ ~~
b.c:4:3: note: array 'ary' declared here
int ary[2] = {233, 666};
^
b.c:5:55: warning: array index 2 is past the end of the array (which contains 2 elements) [-Warray-bounds]
printf("%i, %i, %i, %i\n", ary[0], ary[1], ary[-1], ary[2]);
^ ~
b.c:4:3: note: array 'ary' declared here
int ary[2] = {233, 666};
^
4 warnings generated.
dse@susepc:~$ ./bbb
233, 666, 0, 1936233432


另外上面数组下标越界是一种情况,stackoverflow 也是一种溢出
内存溢出容易和分配失败混淆
下面是明显一点的:

测试
extern printf

section .text
global _start

_start:
push fmt
push 0
call printf
leave
ret

section .data
fmt: db '%i', 0

nasm b.s -f elf64 -o bbb; chmod +x bbb; ld bbb -lc -Bdynamic -I/lib64/ld-linux-x86-64.so.2 -o bb
./bb
然后一直段错误不想开调试器了
于是我就换成内联 assembly

#include <stdio.h>

void prints() {
char fmt[3] = "%i";
asm volatile (
"push %0\n\t"
"push $0\n\t"
"call printf"
: "=r" (fmt)
);
}

int main(int argc, char **argv) {
//printf("%i", 0);
prints();
return 0;
}


然后打开 edb 调试了一下结合 plasm disasm 认为还是 fmt 有问题
累死还没写完
(WASM 是堆栈机方便
欺负我 QAQ
This media is not supported in your browser
VIEW IN TELEGRAM